2 declare(strict_types = 1);
105 $inheritancesResolverService = GeneralUtility::makeInstance(ObjectManager::class)
108 return $inheritancesResolverService;
120 $this->referenceConfiguration = [];
121 $this->inheritanceStack = [];
122 $this->inheritancePathToCheck =
'';
149 $configuration = $this->
resolve($this->referenceConfiguration);
151 return $configuration;
169 array $configuration,
170 array $pathStack = [],
171 bool $setInheritancePathToCheck =
true
173 foreach ($configuration as $key => $values) {
176 $path = implode(
'.', $pathStack);
182 if ($setInheritancePathToCheck) {
183 $this->inheritancePathToCheck = $path;
187 if (is_array($configuration[$key])) {
188 if (isset($configuration[$key][self::INHERITANCE_OPERATOR])) {
189 $inheritances = $this->
getValueByPath($this->referenceConfiguration, $path .
'.' . self::INHERITANCE_OPERATOR);
192 if (is_array($inheritances)) {
194 $configuration[$key] = array_replace_recursive($inheritedConfigurations, $configuration[$key]);
198 unset($configuration[$key][self::INHERITANCE_OPERATOR]);
201 if (!empty($configuration[$key])) {
203 $configuration[$key] = $this->
resolve($configuration[$key], $pathStack);
206 array_pop($pathStack);
209 return $configuration;
223 ksort($inheritances);
224 $inheritedConfigurations = [];
225 foreach ($inheritances as $inheritancePath) {
227 $inheritedConfiguration = $this->
getValueByPath($this->referenceConfiguration, $inheritancePath);
230 isset($inheritedConfiguration[self::INHERITANCE_OPERATOR])
231 && count($inheritedConfiguration) === 1
233 if ($this->inheritancePathToCheck === $inheritancePath) {
234 throw new CycleInheritancesException(
235 $this->inheritancePathToCheck .
' has cycle inheritances',
241 $inheritedConfiguration[self::INHERITANCE_OPERATOR]
244 $pathStack = explode(
'.', $inheritancePath);
245 $key = array_pop($pathStack);
246 $newConfiguration = [
247 $key => $inheritedConfiguration
249 $inheritedConfiguration = $this->
resolve(
254 $inheritedConfiguration = $inheritedConfiguration[$key];
257 if ($inheritedConfiguration ===
null) {
258 throw new CycleInheritancesException(
259 $inheritancePath .
' does not exist within the configuration',
264 $inheritedConfigurations = array_replace_recursive(
265 $inheritedConfigurations,
266 $inheritedConfiguration
270 return $inheritedConfigurations;
282 $configuration = $this->
getValueByPath($this->referenceConfiguration, $path);
284 if (isset($configuration[self::INHERITANCE_OPERATOR])) {
285 $inheritances = $this->
getValueByPath($this->referenceConfiguration, $path .
'.' . self::INHERITANCE_OPERATOR);
287 if (is_array($inheritances)) {
288 foreach ($inheritances as $inheritancePath) {
289 $configuration = $this->
getValueByPath($this->referenceConfiguration, $inheritancePath);
291 if (isset($configuration[self::INHERITANCE_OPERATOR])) {
292 $_inheritances = $this->
getValueByPath($this->referenceConfiguration, $inheritancePath .
'.' . self::INHERITANCE_OPERATOR);
294 foreach ($_inheritances as $_inheritancePath) {
295 if (strpos($pathToCheck, $_inheritancePath) === 0) {
296 throw new CycleInheritancesException(
297 $pathToCheck .
' has cycle inheritances',
305 isset($this->inheritanceStack[$pathToCheck])
306 && is_array($this->inheritanceStack[$pathToCheck])
307 && in_array($inheritancePath, $this->inheritanceStack[$pathToCheck])
309 $this->inheritanceStack[$pathToCheck][] = $inheritancePath;
310 throw new CycleInheritancesException(
311 $pathToCheck .
' has cycle inheritances',
315 $this->inheritanceStack[$pathToCheck][] = $inheritancePath;
318 $this->inheritanceStack[$pathToCheck] =
null;
332 foreach ($result as $key => $value) {
333 if ($key === self::INHERITANCE_OPERATOR) {
334 unset($result[$key]);
338 if (is_array($value)) {
354 protected function getValueByPath(array $config,
string $path,
string $delimiter =
'.')
358 }
catch (MissingArrayPathException $exception) {