diff --git a/Classes/Sizes/AbstractContentElement.php b/Classes/Sizes/AbstractContentElement.php index 4ddd504..153b630 100644 --- a/Classes/Sizes/AbstractContentElement.php +++ b/Classes/Sizes/AbstractContentElement.php @@ -94,11 +94,11 @@ protected function readConfigurationByPath(string $configurationPath): array if (is_array($configuration)) { if (isset($configuration['multiplier'])) { - $multiplier = array_map(static fn($multiplier): float => Multiplier::parse($multiplier), $configuration['multiplier']); + $multiplier = array_map(static fn ($multiplier): float => Multiplier::parse($multiplier), $configuration['multiplier']); } if (isset($configuration['sizes'])) { - $sizes = array_map(static fn($size): int => (int)$size, $configuration['sizes']); + $sizes = array_map(static fn ($size): int => (int) $size, $configuration['sizes']); } } diff --git a/Classes/Sizes/Container.php b/Classes/Sizes/Container.php index b843d54..cb6f890 100644 --- a/Classes/Sizes/Container.php +++ b/Classes/Sizes/Container.php @@ -92,7 +92,6 @@ public function readConfiguration(): void $this->contentType, ]); - [$multiplier, $sizes] = $this->readConfigurationByPath($configurationPath); $this->multiplier = $multiplier; diff --git a/Classes/Sizes/Rootline.php b/Classes/Sizes/Rootline.php index c29ad7f..a84ac3b 100644 --- a/Classes/Sizes/Rootline.php +++ b/Classes/Sizes/Rootline.php @@ -59,6 +59,32 @@ public function getFinalSizes(): array return $this->finalSizes; } + public function getSizesAndMultiplierFromContentElement( + mixed $contentElement, + array $sizes, + array $multiplier + ): array { + if ($contentElement instanceof ContentElementInterface) { + if ($contentElement instanceof Container) { + $sizes = $contentElement->getActiveColumn()->getSizes(); + if (!empty($sizes)) { + return [$sizes, $multiplier]; + } + + $multiplier[] = $contentElement->getActiveColumn()->getMultiplier(); + } + + $sizes = $contentElement->getSizes(); + if (!empty($sizes)) { + return [$sizes, $multiplier]; + } + + $multiplier[] = $contentElement->getMultiplier(); + } + + return [$sizes, $multiplier]; + } + private function determineBackendLayout(): void { $typoscriptFrontendController = $GLOBALS['TSFE']; @@ -144,31 +170,17 @@ private function calculateSizes(): void private function getSizesAndMultiplierFromRootline(): array { $multiplier = []; - $sizes = []; foreach ($this->rootline as $contentElement) { - if ($contentElement instanceof ContentElementInterface) { - if ($contentElement instanceof Container) { - $sizes = $contentElement->getActiveColumn()->getSizes(); - if (!empty($sizes)) { - break; - } - - $multiplier[] = $contentElement->getActiveColumn()->getMultiplier(); - } + $sizes = []; + [$sizes, $multiplier] = $this->getSizesAndMultiplierFromContentElement($contentElement, $sizes, $multiplier); - $sizes = $contentElement->getSizes(); - if (!empty($sizes)) { - break; - } - - $multiplier[] = $contentElement->getMultiplier(); + if (!empty($sizes)) { + return [$sizes, $multiplier]; } } - if (empty($sizes)) { - $sizes = $this->backendLayout->getSizes(); - } + $sizes = $this->backendLayout->getSizes(); return [$sizes, $multiplier]; }