protected function mergePrototypesWithConfigurationForPathSegment($configuration, &$currentPrototypeDefinitions)
{
$currentPathSegmentType = $configuration['__objectType'];
if (isset($currentPrototypeDefinitions[$currentPathSegmentType])) {
$prototypeMergingOrder = [$currentPathSegmentType];
if (isset($currentPrototypeDefinitions[$currentPathSegmentType]['__prototypeChain'])) {
$prototypeMergingOrder = array_merge($currentPrototypeDefinitions[$currentPathSegmentType]['__prototypeChain'], $prototypeMergingOrder);
}
$currentPrototypeWithInheritanceTakenIntoAccount = [];
foreach ($prototypeMergingOrder as $prototypeName) {
if (!array_key_exists($prototypeName, $currentPrototypeDefinitions)) {
throw new Exception(sprintf('The TypoScript object `%s` which you tried to inherit from does not exist.
Maybe you have a typo on the right hand side of your inheritance statement for `%s`.', $prototypeName, $currentPathSegmentType), 1427134340);
}
$currentPrototypeWithInheritanceTakenIntoAccount = Arrays::arrayMergeRecursiveOverruleWithCallback($currentPrototypeWithInheritanceTakenIntoAccount, $currentPrototypeDefinitions[$prototypeName], $this->simpleTypeToArrayClosure);
}
// We merge the already flattened prototype with the current configuration (in that order),
// to make sure that the current configuration (not being defined in the prototype) wins.
$configuration = Arrays::arrayMergeRecursiveOverruleWithCallback($currentPrototypeWithInheritanceTakenIntoAccount, $configuration, $this->simpleTypeToArrayClosure);
// If context-dependent prototypes are set (such as prototype("foo").prototype("baz")),
// we update the current prototype definitions.
if (isset($currentPrototypeWithInheritanceTakenIntoAccount['__prototypes'])) {
$currentPrototypeDefinitions = Arrays::arrayMergeRecursiveOverruleWithCallback($currentPrototypeDefinitions, $currentPrototypeWithInheritanceTakenIntoAccount['__prototypes'], $this->simpleTypeToArrayClosure);
}
}
return $configuration;
}