diff --git a/Classes/Configuration/ConfigurationManager.php b/Classes/Configuration/ConfigurationManager.php index 5b50bb1..449d147 100644 --- a/Classes/Configuration/ConfigurationManager.php +++ b/Classes/Configuration/ConfigurationManager.php @@ -40,13 +40,13 @@ public function get(): array return $this->settings; } - public function isValidPath(string $path): bool + public function isValidPath(array|string $path): bool { - return ArrayUtility::isValidPath($this->settings, $path, '.'); + return ArrayUtility::isValidPath($this->settings, $path); } - public function getByPath(string $path): mixed + public function getByPath(array|string $path): mixed { - return ArrayUtility::getValueByPath($this->settings, $path, '.'); + return ArrayUtility::getValueByPath($this->settings, $path); } } diff --git a/Classes/DataProcessing/ResponsiveImagesProcessor.php b/Classes/DataProcessing/ResponsiveImagesProcessor.php index 8b90e3b..e744c31 100644 --- a/Classes/DataProcessing/ResponsiveImagesProcessor.php +++ b/Classes/DataProcessing/ResponsiveImagesProcessor.php @@ -125,7 +125,7 @@ private function getBreakpoints(): array { $breakpoints = []; - $breakpointsByPath = $this->configurationManager->getByPath('breakpoints'); + $breakpointsByPath = $this->configurationManager->getByPath(['breakpoints']); if (is_iterable($breakpointsByPath)) { foreach ($breakpointsByPath as $breakpointIdentifier => $breakpointData) { diff --git a/Classes/Domain/Factory/BackendLayoutFactory.php b/Classes/Domain/Factory/BackendLayoutFactory.php index 9c363f2..4897c33 100644 --- a/Classes/Domain/Factory/BackendLayoutFactory.php +++ b/Classes/Domain/Factory/BackendLayoutFactory.php @@ -30,21 +30,23 @@ class BackendLayoutFactory { public function __construct( - private ConfigurationManager $configurationManager, + private readonly ConfigurationManager $configurationManager, private readonly ScalingFactory $scalingFactory ) { } - public function create(string $configurationPath): BackendLayoutInterface + public function create(array $configurationPath): BackendLayoutInterface { $scaling = $this->scalingFactory->getByConfigurationPath($configurationPath); - $columns = $this->determineColumns($configurationPath . '.columns'); + $configurationPath[] = 'columns'; + + $columns = $this->determineColumns($configurationPath); return new BackendLayout($scaling, $columns); } - private function determineColumns(string $configurationPath): array + private function determineColumns(array $configurationPath): array { $columns = $this->configurationManager->getByPath($configurationPath); assert(is_array($columns)); diff --git a/Classes/Domain/Factory/RootlineElementFactory.php b/Classes/Domain/Factory/RootlineElementFactory.php index 12e0be1..cb58e48 100644 --- a/Classes/Domain/Factory/RootlineElementFactory.php +++ b/Classes/Domain/Factory/RootlineElementFactory.php @@ -33,7 +33,7 @@ public function __construct( ) { } - public function create(array $data, string $configurationPath): RootlineElementInterface + public function create(array $data, array|string $configurationPath): RootlineElementInterface { $scaling = $this->scalingFactory->getByConfigurationPath($configurationPath); diff --git a/Classes/Domain/Factory/RootlineFactory.php b/Classes/Domain/Factory/RootlineFactory.php index aa1a865..4085b95 100644 --- a/Classes/Domain/Factory/RootlineFactory.php +++ b/Classes/Domain/Factory/RootlineFactory.php @@ -69,7 +69,12 @@ public function determineContainerColumn( ): RootlineElementInterface { $newContainerColumn = $this->rootlineElementFactory->create( $data, - $this->getConfigPathForContainerColumn($data['CType'], $contentElement) + [ + 'container', + $data['CType'], + 'columns', + (string) $contentElement->getColPos(), + ] ); $contentElement->setParent($newContainerColumn); @@ -86,7 +91,10 @@ private function determineBackendLayout(): void ); $this->backendLayout = $this->backendLayoutFactory->create( - $this->getConfigPathForBackendLayout() + [ + 'backendlayouts', + $this->backendLayoutIdentifier, + ] ); } @@ -94,40 +102,48 @@ private function determineBackendLayoutColumn(RootlineElementInterface $contentE { $newBackendLayoutColumn = $this->rootlineElementFactory->create( [], - $this->getConfigPathForBackendLayoutColumn($contentElement) + [ + 'backendlayouts', + $this->backendLayoutIdentifier, + 'columns', + (string) $contentElement->getColPos(), + ] ); $newBackendLayoutColumn->setParent($this->backendLayout); $contentElement->setParent($newBackendLayoutColumn); } - private function determineContentElement( - array $data, - string $fieldName - ): RootlineElementInterface { - return $this->rootlineElementFactory->create( - $data, - implode('.', [ - 'contentelements', - $data['CType'], - $fieldName, - ]) - ); - } - private function determineContainer(array $data, RootlineElementInterface $contentElement): RootlineElementInterface { $newContainerColumn = $this->determineContainerColumn($data, $contentElement); $newContainer = $this->rootlineElementFactory->create( $data, - $this->getConfigPathForContainer($data['CType']) + [ + 'container', + $data['CType'], + ] ); $newContainerColumn->setParent($newContainer); return $newContainer; } + private function determineContentElement( + array $data, + string $fieldName + ): RootlineElementInterface { + return $this->rootlineElementFactory->create( + $data, + [ + 'contentelements', + $data['CType'], + $fieldName, + ] + ); + } + private function determineRootline(RootlineElementInterface $contentElement): void { if (in_array($contentElement->getColPos(), $this->backendLayout->getColumns(), true)) { @@ -148,38 +164,4 @@ private function determineRootline(RootlineElementInterface $contentElement): vo $this->determineRootline($parent); } } - - private function getConfigPathForContainer(string $CType): string - { - return implode('.', [ - 'container', - $CType, - ]); - } - - private function getConfigPathForContainerColumn(string $CType, RootlineElementInterface $contentElement): string - { - return implode('.', [ - $this->getConfigPathForContainer($CType), - 'columns', - (string) $contentElement->getColPos(), - ]); - } - - private function getConfigPathForBackendLayout(): string - { - return implode('.', [ - 'backendlayouts', - $this->backendLayoutIdentifier, - ]); - } - - private function getConfigPathForBackendLayoutColumn(RootlineElementInterface $contentElement): string - { - return implode('.', [ - $this->getConfigPathForBackendLayout(), - 'columns', - (string) $contentElement->getColPos(), - ]); - } } diff --git a/Classes/Domain/Factory/ScalingFactory.php b/Classes/Domain/Factory/ScalingFactory.php index b362237..83ce0c4 100644 --- a/Classes/Domain/Factory/ScalingFactory.php +++ b/Classes/Domain/Factory/ScalingFactory.php @@ -34,7 +34,7 @@ public function __construct( ) { } - public function getByConfigurationPath(string $configurationPath): Scaling + public function getByConfigurationPath(array|string $configurationPath): Scaling { $configuration = $this->configurationManager->getByPath($configurationPath); $multiplier = [];