‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader Class Reference
Inheritance diagram for TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader:

Public Member Functions

array load (string $fileName, int $flags=self::PROCESS_PLACEHOLDERS|self::PROCESS_IMPORTS)
 

Public Attributes

const PATTERN_PARTS = '%[^(%]+?\‍([\'"]?([^(]*?)[\'"]?\‍)%|%([^%()]*?)%'
 
const PROCESS_PLACEHOLDERS = 1
 
const PROCESS_IMPORTS = 2
 

Protected Member Functions

array loadAndParse (string $fileName, ?string $currentFileName)
 
string getFileContents (string $fileName)
 
string getStreamlinedFileName (string $fileName, ?string $currentFileName)
 
 processImports (array $content, ?string $fileName)
 
array processPlaceholders (array $content, array $referenceArray)
 
mixed processPlaceholderLine (string $line, array $referenceArray)
 
mixed processSinglePlaceholder (string $placeholder, string $value, array $referenceArray)
 
 getParts (string $placeholders)
 
 containsPlaceholder (mixed $value)
 
 hasFlag (int $flag)
 

Private Attributes

int $flags
 

Detailed Description

A YAML file loader that allows to load YAML files, based on the Symfony/Yaml component

In addition to just load a YAML file, it adds some special functionality.

  • ‪A special "imports" key in the YAML file allows to include other YAML files recursively. The actual YAML file gets loaded after the import statements, which are interpreted first, at the very beginning. Imports can be referenced with a relative path.
  • ‪Merging configuration options of import files when having simple "lists" will add items to the list instead of overwriting them.
  • ‪Special placeholder values set via optionA.suboptionB% replace the value with the named path of the configuration The placeholders will act as a full replacement of this value.
  • ‪Environment placeholder values set via env(option)% will be replaced by env variables of the same name

Definition at line 46 of file YamlFileLoader.php.

Member Function Documentation

◆ containsPlaceholder()

TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::containsPlaceholder ( mixed  $value)
protected

Finds possible placeholders. May find false positives for complexer structures, but they will be sorted later on.

Definition at line 270 of file YamlFileLoader.php.

Referenced by TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processPlaceholderLine(), and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processPlaceholders().

◆ getFileContents()

string TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::getFileContents ( string  $fileName)
protected

Put into a separate method to ease the pains with unit tests

Returns
‪string the contents or empty string if file_get_contents fails

Definition at line 106 of file YamlFileLoader.php.

Referenced by TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\loadAndParse().

◆ getParts()

TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::getParts ( string  $placeholders)
protected

◆ getStreamlinedFileName()

string TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::getStreamlinedFileName ( string  $fileName,
?string  $currentFileName 
)
protected

Fetches the absolute file name, but if a different file name is given, it is built relative to that.

Parameters
string$fileName‪either relative to TYPO3's base project folder or prefixed with EXT:...
string | null$currentFileName‪when called recursively this contains the absolute file name of the file that included this file
Returns
‪string the contents of the file
Exceptions
YamlFileLoadingException‪when the file was not accessible

Definition at line 119 of file YamlFileLoader.php.

References TYPO3\CMS\Core\Utility\PathUtility\getAbsolutePathOfRelativeReferencedFileOrPath(), TYPO3\CMS\Core\Utility\PathUtility\isAbsolutePath(), and TYPO3\CMS\Core\Utility\PathUtility\isExtensionPath().

Referenced by TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\loadAndParse(), and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processImports().

◆ hasFlag()

TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::hasFlag ( int  $flag)
protected

◆ load()

array TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::load ( string  $fileName,
int  $flags = self::PROCESS_PLACEHOLDERS | self::PROCESS_IMPORTS 
)

Loads and parses a YAML file, and returns an array with the found data

Parameters
string$fileName‪either relative to TYPO3's base project folder or prefixed with EXT:...
int$flags‪Flags to configure behaviour of the loader: see public PROCESS_ constants above
Returns
‪array the configuration as array

Definition at line 65 of file YamlFileLoader.php.

References TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\$flags, and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\loadAndParse().

◆ loadAndParse()

array TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::loadAndParse ( string  $fileName,
?string  $currentFileName 
)
protected

Internal method which does all the logic. Built so it can be re-used recursively.

Parameters
string$fileName‪either relative to TYPO3's base project folder or prefixed with EXT:...
string | null$currentFileName‪when called recursively
Returns
‪array the configuration as array

Definition at line 78 of file YamlFileLoader.php.

References TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\getFileContents(), TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\getStreamlinedFileName(), TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\hasFlag(), TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processImports(), and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processPlaceholders().

Referenced by TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\load(), and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processImports().

◆ processImports()

TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::processImports ( array  $content,
?string  $fileName 
)
protected

◆ processPlaceholderLine()

mixed TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::processPlaceholderLine ( string  $line,
array  $referenceArray 
)
protected

◆ processPlaceholders()

array TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::processPlaceholders ( array  $content,
array  $referenceArray 
)
protected

Main function that gets called recursively to check for %...% placeholders inside the array

Parameters
array$content‪the current sub-level content array
array$referenceArray‪the global configuration array
Returns
‪array the modified sub-level content array

Definition at line 187 of file YamlFileLoader.php.

References TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\containsPlaceholder(), and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processPlaceholderLine().

Referenced by TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\loadAndParse(), TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processImports(), and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processSinglePlaceholder().

◆ processSinglePlaceholder()

mixed TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::processSinglePlaceholder ( string  $placeholder,
string  $value,
array  $referenceArray 
)
protected

Member Data Documentation

◆ $flags

int TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::$flags
private

◆ PATTERN_PARTS

const TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::PATTERN_PARTS = '%[^(%]+?\‍([\'"]?([^(]*?)[\'"]?\‍)%|%([^%()]*?)%'

◆ PROCESS_IMPORTS

◆ PROCESS_PLACEHOLDERS

const TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::PROCESS_PLACEHOLDERS = 1

Definition at line 51 of file YamlFileLoader.php.