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

Public Member Functions

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

Static Public Member Functions

static create (array $configuration=[])
 

Public Attributes

const INHERITANCE_OPERATOR = '__inheritances'
 

Protected Member Functions

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

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 '__inheritances' 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: __inheritances: 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 63 of file InheritancesResolverService.php.

Member Function Documentation

◆ create()

static 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.

Definition at line 97 of file InheritancesResolverService.php.

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

◆ getResolvedConfiguration()

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

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

Definition at line 138 of file InheritancesResolverService.php.

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

◆ 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;

Returns
‪string|array|null

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

Returns
‪array the modified array

Definition at line 318 of file InheritancesResolverService.php.

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

◆ removeVendorNamespaceFromInheritancePath()

TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService::removeVendorNamespaceFromInheritancePath ( string  $inheritancePath)
protected

◆ 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 111 of file InheritancesResolverService.php.

◆ resolve()

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

Definition at line 158 of file InheritancesResolverService.php.

References 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()

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

◆ 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.

Returns
InheritancesResolverService

Definition at line 125 of file InheritancesResolverService.php.

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

◆ throwExceptionIfCycleInheritances()

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

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 89 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 82 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 75 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 68 of file InheritancesResolverService.php.