‪TYPO3CMS  10.4
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)
 
array 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)
 
array getParts (string $placeholders)
 
bool containsPlaceholder ($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 47 of file YamlFileLoader.php.

Member Function Documentation

◆ containsPlaceholder()

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

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

Parameters
$value
Returns
‪bool

Definition at line 280 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

Parameters
string$fileName
Returns
‪string the contents

Definition at line 108 of file YamlFileLoader.php.

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

◆ getParts()

array TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader::getParts ( string  $placeholders)
protected
Parameters
string$placeholders
Returns
‪array

Definition at line 257 of file YamlFileLoader.php.

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

◆ 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 121 of file YamlFileLoader.php.

References TYPO3\CMS\Core\Utility\PathUtility\getAbsolutePathOfRelativeReferencedFileOrPath().

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

◆ 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 66 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 79 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()

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

Checks for the special "imports" key on the main level of a file, which calls "load" recursively.

Parameters
array$content
string | null$fileName
Returns
‪array

Definition at line 155 of file YamlFileLoader.php.

References TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\loadAndParse(), TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processPlaceholders(), and TYPO3\CMS\Core\Utility\ArrayUtility\replaceAndAppendScalarValuesRecursive().

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

◆ 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 185 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
Parameters
string$placeholder
string$value
array$referenceArray
Returns
‪mixed

Definition at line 231 of file YamlFileLoader.php.

References $GLOBALS, and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\processPlaceholders().

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

Member Data Documentation

◆ $flags

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

◆ PATTERN_PARTS

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

Definition at line 51 of file YamlFileLoader.php.

◆ PROCESS_IMPORTS

◆ PROCESS_PLACEHOLDERS

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

Definition at line 52 of file YamlFileLoader.php.