‪TYPO3CMS  10.4
TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService Class Reference

Public Member Functions

InheritancesResolverService reset ()
 
InheritancesResolverService setReferenceConfiguration (array $referenceConfiguration)
 
array getResolvedConfiguration ()
 

Static Public Member Functions

static InheritancesResolverService create (array $configuration=[])
 

Public Attributes

const INHERITANCE_OPERATOR = '__inheritances'
 

Protected Member Functions

array resolve (array $configuration, array $pathStack=[], bool $setInheritancePathToCheck=true)
 
array resolveInheritancesRecursive (array $inheritances)
 
 throwExceptionIfCycleInheritances (string $path, string $pathToCheck)
 
array removeInheritanceOperatorRecursive (array $array)
 
string array null getValueByPath (array $config, string $path, string $delimiter='.')
 

Protected Attributes

array $referenceConfiguration = array( )
 
array $inheritanceStack = array( )
 
string $inheritancePathToCheck = ''
 

Detailed Description

Resolve declared inheritances within a configuration array

Basic concept:

  • ‪Take a large YAML config and replace the key '__inheritance' by the referenced YAML partial (of the same config file)
  • ‪Maybe also override some keys of the referenced partial
  • ‪Avoid endless loop by reference cycles

e.g.

Form: part1: key1: value1 key2: value2 key3: value3 part2: __inheritance: 10: Form.part1 key2: another_value

will result in:

Form: part1: key1: value1 key2: value2 key3: value3 part2: key1: value1 key2: another_value key3: value3


Scope: frontend / backend

Definition at line 65 of file InheritancesResolverService.php.

Member Function Documentation

◆ create()

static InheritancesResolverService TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::create ( array  $configuration = [])
static

Returns an instance of this service. Additionally the configuration which should be resolved can be passed.

Parameters
array$configuration
Returns
InheritancesResolverService

Definition at line 102 of file InheritancesResolverService.php.

References TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\setReferenceConfiguration().

Referenced by TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManager\getConfigurationFromYamlFile().

◆ getResolvedConfiguration()

array TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::getResolvedConfiguration ( )

Resolve all inheritances within a configuration. After that the configuration array is cleaned from the inheritance operator.

Returns
‪array

Definition at line 147 of file InheritancesResolverService.php.

References TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\removeInheritanceOperatorRecursive(), and TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolve().

Referenced by TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManager\getConfigurationFromYamlFile().

◆ getValueByPath()

string array null TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::getValueByPath ( array  $config,
string  $path,
string  $delimiter = '.' 
)
protected

Check the given array representation of a YAML config for the given path and return it's value / sub-array. If path is not found, return null;

Parameters
array$config
string$path
string$delimiter
Returns
‪string|array|null

Definition at line 369 of file InheritancesResolverService.php.

References TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath().

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolve(), TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolveInheritancesRecursive(), and TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\throwExceptionIfCycleInheritances().

◆ removeInheritanceOperatorRecursive()

array TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::removeInheritanceOperatorRecursive ( array  $array)
protected

Recursively remove self::INHERITANCE_OPERATOR keys

Parameters
array$array
Returns
‪array the modified array

Definition at line 344 of file InheritancesResolverService.php.

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\getResolvedConfiguration().

◆ reset()

InheritancesResolverService TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::reset ( )

Reset the state of this service. Mainly introduced for unit tests.

Returns
InheritancesResolverService

Definition at line 118 of file InheritancesResolverService.php.

◆ resolve()

array TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::resolve ( array  $configuration,
array  $pathStack = [],
bool  $setInheritancePathToCheck = true 
)
protected

Resolve all inheritances within a configuration.

Takes a YAML config mapped to associative array $configuration

  • ‪replace all findings of key '__inheritance' recursively
  • ‪perform a deep search in config by iteration, thus check for endless loop by reference cycle

Return the completed configuration.

Parameters
array$configuration‪- a mapped YAML configuration (full or partial)
array$pathStack‪- an identifier for YAML key as array (Form.part1.key => {Form, part1, key})
bool$setInheritancePathToCheck
Returns
‪array

Definition at line 168 of file InheritancesResolverService.php.

References TYPO3\CMS\Core\Utility\StringUtility\beginsWith(), TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\getValueByPath(), TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolveInheritancesRecursive(), and TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\throwExceptionIfCycleInheritances().

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\getResolvedConfiguration(), and TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolveInheritancesRecursive().

◆ resolveInheritancesRecursive()

array TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::resolveInheritancesRecursive ( array  $inheritances)
protected

Additional helper for the resolve method.

Takes all inheritances (an array of YAML paths), and check them for endless loops

Parameters
array$inheritances
Returns
‪array
Exceptions
CycleInheritancesException

Definition at line 236 of file InheritancesResolverService.php.

References TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\getValueByPath(), TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolve(), and TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\throwExceptionIfCycleInheritances().

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolve().

◆ setReferenceConfiguration()

InheritancesResolverService TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::setReferenceConfiguration ( array  $referenceConfiguration)

Set the reference configuration which is used to get untouched values which can be merged into the touched configuration.

Parameters
array$referenceConfiguration
Returns
InheritancesResolverService

Definition at line 133 of file InheritancesResolverService.php.

References TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\$referenceConfiguration.

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\create().

◆ throwExceptionIfCycleInheritances()

TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::throwExceptionIfCycleInheritances ( string  $path,
string  $pathToCheck 
)
protected

Throw an exception if a cycle is detected.

Parameters
string$path
string$pathToCheck
Exceptions
CycleInheritancesException

Definition at line 295 of file InheritancesResolverService.php.

References TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\getValueByPath().

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolve(), and TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\resolveInheritancesRecursive().

Member Data Documentation

◆ $inheritancePathToCheck

string TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::$inheritancePathToCheck = ''
protected

Needed to buffer a configuration path for cyclically inheritances detection while inheritances for this path is ongoing.

Definition at line 92 of file InheritancesResolverService.php.

◆ $inheritanceStack

array TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::$inheritanceStack = array( )
protected

This stack is needed to find cyclically inheritances which are on the same nesting level but which do not follow each other directly.

Definition at line 85 of file InheritancesResolverService.php.

◆ $referenceConfiguration

array TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::$referenceConfiguration = array( )
protected

The reference configuration is used to get untouched values which can be merged into the touched configuration.

Definition at line 78 of file InheritancesResolverService.php.

Referenced by TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService\setReferenceConfiguration().

◆ INHERITANCE_OPERATOR

const TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::INHERITANCE_OPERATOR = '__inheritances'

The operator which is used to declare inheritances

Definition at line 71 of file InheritancesResolverService.php.