TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
InheritancesResolverService Class Reference

Public Member Functions

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

Public Attributes

const INHERITANCE_OPERATOR = '__inheritances'
 

Protected Member Functions

 resolve (array $configuration, array $pathStack=[], bool $setInheritancePathToCkeck=true)
 
 resolveInheritancesRecursive (array $inheritances)
 
 throwExceptionIfCycleInheritances (string $path, string $pathToCheck)
 
 removeInheritanceOperatorRecursive (array $array)
 
 mergeRecursiveWithOverrule (array $firstArray, array $secondArray, bool $dontAddNewKeys=false, bool $emptyValuesOverride=true)
 

Protected Attributes

 $referenceConfiguration = []
 
 $inheritanceStack = []
 
 $inheritancePathToCkeck = ''
 

Detailed Description

Resolve declared inheritances within an configuration array

Scope: frontend / backend

Definition at line 29 of file InheritancesResolverService.php.

Member Function Documentation

getResolvedConfiguration ( )

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

Returns
array

Definition at line 114 of file InheritancesResolverService.php.

References InheritancesResolverService\removeInheritanceOperatorRecursive(), and InheritancesResolverService\resolve().

mergeRecursiveWithOverrule ( array  $firstArray,
array  $secondArray,
bool  $dontAddNewKeys = false,
bool  $emptyValuesOverride = true 
)
protected

Merges two arrays recursively and "binary safe" (integer keys are overridden as well), overruling similar values in the first array ($firstArray) with the values of the second array ($secondArray) In case of identical keys, ie. keeping the values of the second. This is basicly the Extbase arrayMergeRecursiveOverrule method. This method act different to the core mergeRecursiveWithOverrule method. This method has the possibility to overrule a array value within the $firstArray with a string value within the $secondArray. The core method does not support such a overrule. The reason for this code duplication is that the extbase method will be deprecated in the future.

Parameters
array$firstArrayFirst array
array$secondArraySecond array, overruling the first array
bool$dontAddNewKeysIf set, keys that are NOT found in $firstArray (first array) will not be set. Thus only existing value can/will be overruled from second array.
bool$emptyValuesOverrideIf set (which is the default), values from $secondArray will overrule if they are empty (according to PHP's empty() function)
Returns
array Resulting array where $secondArray values has overruled $firstArray values

Definition at line 370 of file InheritancesResolverService.php.

References InheritancesResolverService\reset().

Referenced by InheritancesResolverService\resolve(), and InheritancesResolverService\resolveInheritancesRecursive().

removeInheritanceOperatorRecursive ( array  $array)
protected

Recursively remove self::INHERITANCE_OPERATOR keys

Parameters
array$array
Returns
array the modified array

Definition at line 331 of file InheritancesResolverService.php.

Referenced by InheritancesResolverService\getResolvedConfiguration().

reset ( )

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

Returns
InheritancesResolverService

Definition at line 85 of file InheritancesResolverService.php.

Referenced by InheritancesResolverService\mergeRecursiveWithOverrule().

resolve ( array  $configuration,
array  $pathStack = [],
bool  $setInheritancePathToCkeck = true 
)
protected

Resolve all inheritances within a configuration.

: More description

Parameters
array$configuration
array$pathStack
bool$setInheritancePathToCkeck
Returns
array

Definition at line 130 of file InheritancesResolverService.php.

References ArrayUtility\getValueByPath(), InheritancesResolverService\mergeRecursiveWithOverrule(), InheritancesResolverService\resolveInheritancesRecursive(), and InheritancesResolverService\throwExceptionIfCycleInheritances().

Referenced by InheritancesResolverService\getResolvedConfiguration(), and InheritancesResolverService\resolveInheritancesRecursive().

resolveInheritancesRecursive ( array  $inheritances)
protected

Additional helper for the resolve method.

: More description

Parameters
array$inheritances
Returns
array
Exceptions
CycleInheritancesException

Definition at line 189 of file InheritancesResolverService.php.

References ArrayUtility\getValueByPath(), InheritancesResolverService\mergeRecursiveWithOverrule(), InheritancesResolverService\resolve(), and InheritancesResolverService\throwExceptionIfCycleInheritances().

Referenced by InheritancesResolverService\resolve().

setReferenceConfiguration ( array  $referenceConfiguration)

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

Parameters
array
Returns
InheritancesResolverService

Definition at line 100 of file InheritancesResolverService.php.

References InheritancesResolverService\$referenceConfiguration.

throwExceptionIfCycleInheritances ( string  $path,
string  $pathToCheck 
)
protected

Throw an exception if a cycle is detected.

: More description

Parameters
string$path
string$pathToCheck
Returns
void
Exceptions
CycleInheritancesException

Definition at line 251 of file InheritancesResolverService.php.

References ArrayUtility\getValueByPath().

Referenced by InheritancesResolverService\resolve(), and InheritancesResolverService\resolveInheritancesRecursive().

Member Data Documentation

$inheritancePathToCkeck = ''
protected

Definition at line 59 of file InheritancesResolverService.php.

$inheritanceStack = []
protected

Definition at line 51 of file InheritancesResolverService.php.

$referenceConfiguration = []
protected
const INHERITANCE_OPERATOR = '__inheritances'

The operator which is used to declare inheritances

Definition at line 35 of file InheritancesResolverService.php.