TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:27 +02:00
commit 44c503b2d1
233 changed files with 31556 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Frontend\Content;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayout;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Page\ContentArea;
use TYPO3\CMS\Core\Page\ContentAreaClosure;
use TYPO3\CMS\Core\Page\ContentSlideMode;
use TYPO3\CMS\Core\Page\ResolveContentAreasEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
final readonly class ContentAreaResolver
{
public function __construct(private RecordCollector $recordCollector) {}
#[AsEventListener]
public function __invoke(ResolveContentAreasEvent $event): void
{
$layout = $event->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<mixed>|array{
* colPos: string|int,
* name?: string|int,
* slideMode?: string,
* identifier?: string|int,
* allowedContentTypes?: string,
* disallowedContentTypes?: string,
* } $structure
* @param array<string, ContentAreaClosure> $contentAreas
* @return array<string, ContentAreaClosure>
*/
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;
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Frontend\Content;
use TYPO3\CMS\Core\Domain\Persistence\RecordIdentityMap;
use TYPO3\CMS\Core\Domain\RecordFactory;
use TYPO3\CMS\Core\Domain\RecordInterface;
use TYPO3\CMS\Core\Page\ContentSlideMode;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* Executes a SQL query, and retrieves TCA-based records for Frontend rendering.
*/
readonly class RecordCollector
{
public function __construct(
protected RecordFactory $recordFactory
) {}
public function collect(
string $table,
array $select,
ContentSlideMode $slideMode,
ContentObjectRenderer $contentObjectRenderer,
?RecordIdentityMap $recordIdentityMap = null,
): array {
$slideCollectReverse = false;
$collect = false;
switch ($slideMode) {
case ContentSlideMode::Slide:
$slide = true;
break;
case ContentSlideMode::Collect:
$slide = true;
$collect = true;
break;
case ContentSlideMode::CollectReverse:
$slide = true;
$collect = true;
$slideCollectReverse = true;
break;
default:
$slide = false;
}
$again = false;
$totalRecords = [];
do {
$recordsOnPid = $contentObjectRenderer->getRecords($table, $select);
$recordsOnPid = array_map(
fn(array $record): RecordInterface => $this->recordFactory->createResolvedRecordFromDatabaseRow($table, $record, null, $recordIdentityMap),
$recordsOnPid
);
if ($slideCollectReverse) {
$totalRecords = array_merge($totalRecords, $recordsOnPid);
} else {
$totalRecords = array_merge($recordsOnPid, $totalRecords);
}
if ($slide) {
$select['pidInList'] = $contentObjectRenderer->getSlidePids($select['pidInList'] ?? '', $select['pidInList.'] ?? []);
if (isset($select['pidInList.'])) {
unset($select['pidInList.']);
}
$again = $select['pidInList'] !== '';
}
} while ($again && $slide && ($recordsOnPid === [] || $collect));
foreach ($totalRecords as $record) {
$contentObjectRenderer->lastChanged($record);
}
return $totalRecords;
}
}