getBackendLayout(); $fullStructure = $layout->getStructure()['__config']; $contentAreas = $this->collectContentAreasRecursive($fullStructure, $layout); $event->setContentAreas($contentAreas); } /** * Find all arrays recursively from where one of the columns within the array is called "colPos" * * @param array|array{ * colPos: string|int, * name?: string|int, * slideMode?: string, * identifier?: string|int, * allowedContentTypes?: string, * disallowedContentTypes?: string, * } $structure * @param array $contentAreas * @return array */ private function collectContentAreasRecursive(array $structure, BackendLayout $layout, array $contentAreas = []): array { if (isset($structure['colPos'])) { $name = (string)($structure['name'] ?? ''); $colPos = (int)$structure['colPos']; $slideMode = ContentSlideMode::tryFrom($structure['slideMode'] ?? null); $allowedContentTypes = GeneralUtility::trimExplode(',', $structure['allowedContentTypes'] ?? '', true); $disallowedContentTypes = GeneralUtility::trimExplode(',', $structure['disallowedContentTypes'] ?? '', true); $identifier = (string)($structure['identifier'] ?? ''); if ($identifier === '') { throw new \RuntimeException( 'No identifier given for column with colPos "' . $colPos . '" in page layout "' . $layout->getIdentifier() . '". Setting an identifier is mandatory.', 1780173420 ); } $contentAreas[$identifier] = new ContentAreaClosure( function (ServerRequestInterface $request) use ($identifier, $name, $colPos, $slideMode, $allowedContentTypes, $disallowedContentTypes, $structure): ContentArea { $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); $cObj->setRequest($request); $records = $this->recordCollector->collect( 'tt_content', [ 'where' => '{#colPos}=' . $colPos, 'orderBy' => 'sorting', ], $slideMode, $cObj ); return new ContentArea( identifier: $identifier, name: $name, colPos: $colPos, slideMode: $slideMode, allowedContentTypes: $allowedContentTypes, disallowedContentTypes: $disallowedContentTypes, configuration: $structure, records: $records ); } ); // Content Areas cannot be nested. Bubble up and find further areas next to this. return $contentAreas; } foreach ($structure as $value) { if (is_array($value)) { $contentAreas = $this->collectContentAreasRecursive($value, $layout, $contentAreas); } } return $contentAreas; } }