From 375309cbb922145dc2a346d7394485cb6f2b022f Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Tue, 24 Dec 2024 10:48:01 +0100 Subject: [PATCH] [TASK] use ContentObjectRenderer to get container child records for FE cleanup pageview layer unused method in database --- Build/phpstan-baseline-11-7.4.neon | 4 - Build/phpstan-baseline-11.neon | 4 - Build/phpstan-baseline-12.neon | 4 - Build/phpstan-baseline-13.neon | 19 --- Classes/DataProcessing/ContainerProcessor.php | 29 ++--- Classes/Domain/Factory/Database.php | 57 +-------- .../Factory/FrontendContainerFactory.php | 69 ++++++++++ .../PageView/Backend/ContainerFactory.php | 34 ++++- .../PageView/Backend/ContentStorage.php | 65 +++++++++- .../Factory/PageView/ContainerFactory.php | 53 -------- .../Factory/PageView/ContentStorage.php | 84 ------------- .../PageView/Frontend/ContainerFactory.php | 118 ------------------ .../PageView/Frontend/ContentStorage.php | 62 --------- ...ainer_with_ws_child_moved_from_outside.csv | 2 +- .../{ => Backend}/ContainerFactoryTest.php | 8 +- 15 files changed, 183 insertions(+), 429 deletions(-) create mode 100644 Classes/Domain/Factory/FrontendContainerFactory.php delete mode 100644 Classes/Domain/Factory/PageView/ContainerFactory.php delete mode 100644 Classes/Domain/Factory/PageView/ContentStorage.php delete mode 100644 Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php delete mode 100644 Classes/Domain/Factory/PageView/Frontend/ContentStorage.php rename Tests/Unit/Domain/Factory/PageView/{ => Backend}/ContainerFactoryTest.php (77%) diff --git a/Build/phpstan-baseline-11-7.4.neon b/Build/phpstan-baseline-11-7.4.neon index c19f2c57..a7b19873 100644 --- a/Build/phpstan-baseline-11-7.4.neon +++ b/Build/phpstan-baseline-11-7.4.neon @@ -1,9 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:getLanguageOverlay\\(\\) invoked with 3 parameters, 2 required\\.$#" - count: 1 - path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php - message: "#^Constant LF not found\\.$#" diff --git a/Build/phpstan-baseline-11.neon b/Build/phpstan-baseline-11.neon index 89ab997a..a8277c60 100644 --- a/Build/phpstan-baseline-11.neon +++ b/Build/phpstan-baseline-11.neon @@ -1,9 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:getLanguageOverlay\\(\\) invoked with 3 parameters, 2 required\\.$#" - count: 1 - path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php - message: "#^Constant LF not found\\.$#" diff --git a/Build/phpstan-baseline-12.neon b/Build/phpstan-baseline-12.neon index 075d14a6..0bb4bf11 100644 --- a/Build/phpstan-baseline-12.neon +++ b/Build/phpstan-baseline-12.neon @@ -1,9 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Call to protected method getRecordOverlay\\(\\) of class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\.$#" - count: 1 - path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php - message: "#^Constant LF not found\\.$#" diff --git a/Build/phpstan-baseline-13.neon b/Build/phpstan-baseline-13.neon index 123b0cfc..5fcdcf59 100644 --- a/Build/phpstan-baseline-13.neon +++ b/Build/phpstan-baseline-13.neon @@ -1,24 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\Restriction\\\\FrontendWorkspaceRestriction not found\\.$#" - count: 1 - path: ../Classes/Domain/Factory/Database.php - - - - message: "#^Call to protected method getRecordOverlay\\(\\) of class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\.$#" - count: 1 - path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php - - - - message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:getRecordOverlay\\(\\) invoked with 4 parameters, 3 required\\.$#" - count: 1 - path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php - - - - message: "#^Parameter \\#3 \\$languageAspect of method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:getRecordOverlay\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Context\\\\LanguageAspect, int given\\.$#" - count: 1 - path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php - message: "#^Constant LF not found\\.$#" diff --git a/Classes/DataProcessing/ContainerProcessor.php b/Classes/DataProcessing/ContainerProcessor.php index fbf7d0d7..4c58f986 100644 --- a/Classes/DataProcessing/ContainerProcessor.php +++ b/Classes/DataProcessing/ContainerProcessor.php @@ -13,11 +13,10 @@ */ use B13\Container\Domain\Factory\Exception; -use B13\Container\Domain\Factory\PageView\Frontend\ContainerFactory; +use B13\Container\Domain\Factory\FrontendContainerFactory; use B13\Container\Domain\Model\Container; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Context\Context; -use TYPO3\CMS\Core\Context\LanguageAspect; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -25,10 +24,6 @@ class ContainerProcessor implements DataProcessorInterface { - /** - * @var ContainerFactory - */ - protected $containerFactory; /** * @var ContentDataProcessor @@ -36,12 +31,13 @@ class ContainerProcessor implements DataProcessorInterface protected $contentDataProcessor; protected Context $context; + protected FrontendContainerFactory $frontendContainerFactory; - public function __construct(ContainerFactory $containerFactory, ContentDataProcessor $contentDataProcessor, Context $context) + public function __construct(ContentDataProcessor $contentDataProcessor, Context $context, FrontendContainerFactory $frontendContainerFactory) { - $this->containerFactory = $containerFactory; $this->contentDataProcessor = $contentDataProcessor; $this->context = $context; + $this->frontendContainerFactory = $frontendContainerFactory; } public function process( @@ -53,16 +49,15 @@ public function process( if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) { return $processedData; } + $contentId = null; if ($processorConfiguration['contentId.'] ?? false) { $contentId = (int)$cObj->stdWrap($processorConfiguration['contentId'], $processorConfiguration['contentId.']); } elseif ($processorConfiguration['contentId'] ?? false) { $contentId = (int)$processorConfiguration['contentId']; - } else { - $contentId = (int)$cObj->data['uid']; } try { - $container = $this->containerFactory->buildContainer($contentId); + $container = $this->frontendContainerFactory->buildContainer($cObj, $this->context, $contentId); } catch (Exception $e) { // do nothing return $processedData; @@ -109,22 +104,12 @@ protected function processColPos( if ($contentRecordRenderer === null) { throw new ContainerDataProcessingFailedException('RECORDS content object not available.', 1691483526); } - $conf = [ 'tables' => 'tt_content', ]; - /** @var LanguageAspect $languageAspect */ - $languageAspect = $this->context->getAspect('language'); foreach ($children as &$child) { if (!isset($processorConfiguration['skipRenderingChildContent']) || (int)$processorConfiguration['skipRenderingChildContent'] === 0) { - if ($child['l18n_parent'] > 0 && $languageAspect->doOverlays()) { - $conf['source'] = $child['l18n_parent']; - } else { - $conf['source'] = $child['uid']; - } - if ($child['t3ver_oid'] > 0) { - $conf['source'] = $child['t3ver_oid']; - } + $conf['source'] = $child['uid']; $child['renderedContent'] = $cObj->render($contentRecordRenderer, $conf); } /** @var ContentObjectRenderer $recordContentObjectRenderer */ diff --git a/Classes/Domain/Factory/Database.php b/Classes/Domain/Factory/Database.php index cebcf6f0..195143e7 100644 --- a/Classes/Domain/Factory/Database.php +++ b/Classes/Domain/Factory/Database.php @@ -12,18 +12,12 @@ * of the License, or any later version. */ -use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; -use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer; -use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction; -use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction; -use TYPO3\CMS\Core\Http\ApplicationType; -use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -48,33 +42,13 @@ public function __construct(Context $context) protected function getQueryBuilder(): QueryBuilder { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); - if ($this->getServerRequest() instanceof ServerRequestInterface - && ApplicationType::fromRequest($this->getServerRequest())->isFrontend() - ) { - $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); - if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) { - // do not use FrontendWorkspaceRestriction - $queryBuilder->getRestrictions() - ->removeByType(FrontendWorkspaceRestriction::class) - ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $this->workspaceId)); - } - if ($this->workspaceId > 0) { - $queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class); - } - } else { - $queryBuilder->getRestrictions() - ->removeAll() - ->add(GeneralUtility::makeInstance(DeletedRestriction::class)) - ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $this->workspaceId)); - } + $queryBuilder->getRestrictions() + ->removeAll() + ->add(GeneralUtility::makeInstance(DeletedRestriction::class)) + ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $this->workspaceId)); return $queryBuilder; } - protected function getServerRequest(): ?ServerRequestInterface - { - return $GLOBALS['TYPO3_REQUEST'] ?? null; - } - public function fetchRecordsByPidAndLanguage(int $pid, int $language): array { $queryBuilder = $this->getQueryBuilder(); @@ -187,27 +161,4 @@ public function fetchOverlayRecords(array $records, int $language): array ->fetchAllAssociative(); return $rows; } - - public function fetchOneOverlayRecord(int $uid, int $language): ?array - { - $queryBuilder = $this->getQueryBuilder(); - $record = $queryBuilder->select('*') - ->from('tt_content') - ->where( - $queryBuilder->expr()->eq( - 'l18n_parent', - $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT) - ), - $queryBuilder->expr()->eq( - 'sys_language_uid', - $queryBuilder->createNamedParameter($language, Connection::PARAM_INT) - ) - ) - ->executeQuery() - ->fetchAssociative(); - if ($record === false) { - return null; - } - return $record; - } } diff --git a/Classes/Domain/Factory/FrontendContainerFactory.php b/Classes/Domain/Factory/FrontendContainerFactory.php new file mode 100644 index 00000000..b39e78d7 --- /dev/null +++ b/Classes/Domain/Factory/FrontendContainerFactory.php @@ -0,0 +1,69 @@ +tcaRegistry = $tcaRegistry; + } + + public function buildContainer(ContentObjectRenderer $cObj, Context $context, ?int $uid = null): Container + { + if ($uid === null) { + $record = $cObj->data; + } else { + $records = $cObj->getRecords('tt_content', ['where' => 'uid=' . $uid]); + if (empty($records)) { + throw new Exception('no record ' . $uid, 1734946029); + } + $record = $records[0]; + } + if (!$this->tcaRegistry->isContainerElement($record['CType'])) { + throw new Exception('not a container element with uid ' . $uid, 1734946028); + } + $conf = ['where' => 'tx_container_parent=' . $record['uid']]; + /** @var LanguageAspect $languageAspect */ + $languageAspect = $context->getAspect('language'); + if ($languageAspect->getOverlayType() === LanguageAspect::OVERLAYS_OFF && $record['l18n_parent'] > 0) { + $conf['where'] .= ' OR tx_container_parent=' . $record['l18n_parent']; + } + $childRecords = $cObj->getRecords('tt_content', $conf); + $childRecords = $this->recordsByColPosKey($childRecords); + $container = new Container($record, $childRecords, (int)$record['sys_language_uid']); + return $container; + } + + protected function recordsByColPosKey(array $records): array + { + $recordsByColPosKey = []; + foreach ($records as $record) { + if (empty($recordsByColPosKey[$record['colPos']])) { + $recordsByColPosKey[$record['colPos']] = []; + } + $recordsByColPosKey[$record['colPos']][] = $record; + } + return $recordsByColPosKey; + } +} diff --git a/Classes/Domain/Factory/PageView/Backend/ContainerFactory.php b/Classes/Domain/Factory/PageView/Backend/ContainerFactory.php index f0c5d664..6ae67079 100644 --- a/Classes/Domain/Factory/PageView/Backend/ContainerFactory.php +++ b/Classes/Domain/Factory/PageView/Backend/ContainerFactory.php @@ -16,7 +16,7 @@ use B13\Container\Tca\Registry; use TYPO3\CMS\Core\Context\Context; -class ContainerFactory extends \B13\Container\Domain\Factory\PageView\ContainerFactory +class ContainerFactory extends \B13\Container\Domain\Factory\ContainerFactory { /** * @var ContentStorage @@ -32,4 +32,36 @@ public function __construct( parent::__construct($database, $tcaRegistry, $context); $this->contentStorage = $contentStorage; } + + protected function children(array $containerRecord, int $language): array + { + return $this->contentStorage->getContainerChildren($containerRecord, $language); + } + + protected function localizedRecordsByDefaultRecords(array $defaultRecords, int $language): array + { + $childRecords = parent::localizedRecordsByDefaultRecords($defaultRecords, $language); + return $this->contentStorage->workspaceOverlay($childRecords); + } + + protected function containerByUid(int $uid): ?array + { + $record = $this->database->fetchOneRecord($uid); + if ($record === null) { + return null; + } + return $this->contentStorage->containerRecordWorkspaceOverlay($record); + } + + protected function defaultContainer(array $localizedContainer): ?array + { + if (isset($localizedContainer['_ORIG_uid'])) { + $localizedContainer = $this->database->fetchOneRecord((int)$localizedContainer['uid']); + } + $defaultRecord = $this->database->fetchOneDefaultRecord($localizedContainer); + if ($defaultRecord === null) { + return null; + } + return $this->contentStorage->containerRecordWorkspaceOverlay($defaultRecord); + } } diff --git a/Classes/Domain/Factory/PageView/Backend/ContentStorage.php b/Classes/Domain/Factory/PageView/Backend/ContentStorage.php index 5372d985..d591ba1a 100644 --- a/Classes/Domain/Factory/PageView/Backend/ContentStorage.php +++ b/Classes/Domain/Factory/PageView/Backend/ContentStorage.php @@ -12,11 +12,74 @@ * of the License, or any later version. */ +use B13\Container\Domain\Factory\Database; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Versioning\VersionState; -class ContentStorage extends \B13\Container\Domain\Factory\PageView\ContentStorage +class ContentStorage { + /** + * @var ?mixed[] + */ + protected $records; + + /** + * @var Database + */ + protected $database; + + /** + * @var int + */ + protected $workspaceId = 0; + + public function __construct(Database $database, Context $context) + { + $this->database = $database; + $this->workspaceId = (int)$context->getPropertyFromAspect('workspace', 'id'); + } + + protected function buildRecords(int $pid, int $language): array + { + $records = $this->database->fetchRecordsByPidAndLanguage($pid, $language); + $records = $this->workspaceOverlay($records); + $records = $this->recordsByContainer($records); + return $records; + } + + protected function recordsByContainer(array $records): array + { + $recordsByContainer = []; + foreach ($records as $record) { + if ($record['tx_container_parent'] > 0) { + if (empty($recordsByContainer[$record['tx_container_parent']])) { + $recordsByContainer[$record['tx_container_parent']] = []; + } + $recordsByContainer[$record['tx_container_parent']][] = $record; + } + } + return $recordsByContainer; + } + + public function getContainerChildren(array $containerRecord, int $language): array + { + $pid = (int)$containerRecord['pid']; + if (isset($containerRecord['t3ver_oid']) && $containerRecord['t3ver_oid'] > 0) { + $defaultContainerRecord = $this->database->fetchOneRecord((int)$containerRecord['t3ver_oid']); + $uid = (int)$defaultContainerRecord['uid']; + } else { + $uid = (int)$containerRecord['uid']; + } + if (!isset($this->records[$pid][$language])) { + $this->records[$pid][$language] = $this->buildRecords($pid, $language); + } + if (empty($this->records[$pid][$language][$uid])) { + return []; + } + return $this->records[$pid][$language][$uid]; + } + public function workspaceOverlay(array $records): array { $filtered = []; diff --git a/Classes/Domain/Factory/PageView/ContainerFactory.php b/Classes/Domain/Factory/PageView/ContainerFactory.php deleted file mode 100644 index c81d3ab5..00000000 --- a/Classes/Domain/Factory/PageView/ContainerFactory.php +++ /dev/null @@ -1,53 +0,0 @@ -contentStorage->getContainerChildren($containerRecord, $language); - } - - protected function localizedRecordsByDefaultRecords(array $defaultRecords, int $language): array - { - $childRecords = parent::localizedRecordsByDefaultRecords($defaultRecords, $language); - return $this->contentStorage->workspaceOverlay($childRecords); - } - - protected function containerByUid(int $uid): ?array - { - $record = $this->database->fetchOneRecord($uid); - if ($record === null) { - return null; - } - return $this->contentStorage->containerRecordWorkspaceOverlay($record); - } - - protected function defaultContainer(array $localizedContainer): ?array - { - if (isset($localizedContainer['_ORIG_uid'])) { - $localizedContainer = $this->database->fetchOneRecord((int)$localizedContainer['uid']); - } - $defaultRecord = $this->database->fetchOneDefaultRecord($localizedContainer); - if ($defaultRecord === null) { - return null; - } - return $this->contentStorage->containerRecordWorkspaceOverlay($defaultRecord); - } -} diff --git a/Classes/Domain/Factory/PageView/ContentStorage.php b/Classes/Domain/Factory/PageView/ContentStorage.php deleted file mode 100644 index 3fa2cf63..00000000 --- a/Classes/Domain/Factory/PageView/ContentStorage.php +++ /dev/null @@ -1,84 +0,0 @@ -database = $database; - $this->workspaceId = (int)$context->getPropertyFromAspect('workspace', 'id'); - } - - protected function buildRecords(int $pid, int $language): array - { - $records = $this->database->fetchRecordsByPidAndLanguage($pid, $language); - $records = $this->workspaceOverlay($records); - $records = $this->recordsByContainer($records); - return $records; - } - - abstract public function workspaceOverlay(array $records): array; - - abstract public function containerRecordWorkspaceOverlay(array $record): ?array; - - protected function recordsByContainer(array $records): array - { - $recordsByContainer = []; - foreach ($records as $record) { - if ($record['tx_container_parent'] > 0) { - if (empty($recordsByContainer[$record['tx_container_parent']])) { - $recordsByContainer[$record['tx_container_parent']] = []; - } - $recordsByContainer[$record['tx_container_parent']][] = $record; - } - } - return $recordsByContainer; - } - - public function getContainerChildren(array $containerRecord, int $language): array - { - $pid = (int)$containerRecord['pid']; - if (isset($containerRecord['t3ver_oid']) && $containerRecord['t3ver_oid'] > 0) { - $defaultContainerRecord = $this->database->fetchOneRecord((int)$containerRecord['t3ver_oid']); - $uid = (int)$defaultContainerRecord['uid']; - } else { - $uid = (int)$containerRecord['uid']; - } - if (!isset($this->records[$pid][$language])) { - $this->records[$pid][$language] = $this->buildRecords($pid, $language); - } - if (empty($this->records[$pid][$language][$uid])) { - return []; - } - return $this->records[$pid][$language][$uid]; - } -} diff --git a/Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php b/Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php deleted file mode 100644 index 3d82c8c1..00000000 --- a/Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php +++ /dev/null @@ -1,118 +0,0 @@ -contentStorage = $contentStorage; - } - - public function buildContainer(int $uid): Container - { - /** @var LanguageAspect $languageAspect */ - $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); - $language = $languageAspect->getId(); - if ($language > 0 && $languageAspect->doOverlays()) { - return $this->buildContainerWithOverlay($uid, $languageAspect); - } - return parent::buildContainer($uid); - } - - protected function doOverlay(array $defaultRecords, LanguageAspect $languageAspect): array - { - $typo3Version = new Typo3Version(); - $overlayed = []; - $pageRepository = $this->contentStorage->getPageRepository(); - foreach ($defaultRecords as $defaultRecord) { - if ($typo3Version->getMajorVersion() < 12) { - $overlay = $pageRepository->getRecordOverlay( - 'tt_content', - $defaultRecord, - $languageAspect->getContentId(), - $languageAspect->getOverlayType() === $languageAspect::OVERLAYS_MIXED ? '1' : 'hideNonTranslated' - ); - } else { - $overlay = $pageRepository->getLanguageOverlay( - 'tt_content', - $defaultRecord, - $languageAspect - ); - } - if ($overlay !== null) { - $overlayed[] = $overlay; - } - } - return $overlayed; - } - - protected function buildContainerWithOverlay(int $uid, LanguageAspect $languageAspect): Container - { - $language = $languageAspect->get('id'); - $record = $this->database->fetchOneOverlayRecord($uid, $language); - if ($record === null) { - $record = $this->database->fetchOneRecord($uid); - } - - if ($record === null) { - throw new Exception('cannot fetch record with uid ' . $uid, 1576572852); - } - if (!$this->tcaRegistry->isContainerElement($record['CType'])) { - throw new Exception('not a container element with uid ' . $uid, 1576572853); - } - - $defaultRecord = null; - if ($record['sys_language_uid'] > 0) { - $defaultRecord = $this->defaultContainer($record); - if ($defaultRecord === null) { - // free mode - $childRecords = $this->children($record, (int)$record['sys_language_uid']); - } else { - // connected mode - $childRecords = $this->children($defaultRecord, 0); - $childRecords = $this->doOverlay($childRecords, $languageAspect); - } - } else { - // container record with sys_language_uid=0 - $childRecords = $this->children($record, 0); - $childRecords = $this->doOverlay($childRecords, $languageAspect); - } - $childRecordByColPosKey = $this->recordsByColPosKey($childRecords); - if ($defaultRecord === null) { - $container = GeneralUtility::makeInstance(Container::class, $record, $childRecordByColPosKey, $language); - } else { - $container = GeneralUtility::makeInstance(Container::class, $defaultRecord, $childRecordByColPosKey, $language); - } - return $container; - } -} diff --git a/Classes/Domain/Factory/PageView/Frontend/ContentStorage.php b/Classes/Domain/Factory/PageView/Frontend/ContentStorage.php deleted file mode 100644 index 0e5f63f7..00000000 --- a/Classes/Domain/Factory/PageView/Frontend/ContentStorage.php +++ /dev/null @@ -1,62 +0,0 @@ -pageRepository = $pageRepository; - } - - public function getPageRepository(): PageRepository - { - return $this->pageRepository; - } - - public function containerRecordWorkspaceOverlay(array $record): ?array - { - $this->pageRepository->versionOL('tt_content', $record, false); - if (is_array($record)) { - return $record; - } - return null; - } - - public function workspaceOverlay(array $records): array - { - $filtered = []; - foreach ($records as $row) { - $this->pageRepository->versionOL('tt_content', $row, true); - // Language overlay: - if (is_array($row)) { - //$row = $this->pageRepository->getLanguageOverlay('table', $row); - } - // Might be unset in the language overlay - if (is_array($row)) { - $filtered[] = $row; - } - } - return $filtered; - } -} diff --git a/Tests/Functional/Frontend/Fixtures/Workspace/container_with_ws_child_moved_from_outside.csv b/Tests/Functional/Frontend/Fixtures/Workspace/container_with_ws_child_moved_from_outside.csv index 78f879a0..45b07556 100644 --- a/Tests/Functional/Frontend/Fixtures/Workspace/container_with_ws_child_moved_from_outside.csv +++ b/Tests/Functional/Frontend/Fixtures/Workspace/container_with_ws_child_moved_from_outside.csv @@ -2,4 +2,4 @@ ,"uid","pid","CType","header","colPos","tx_container_parent","t3ver_wsid","t3ver_oid","t3ver_state" ,200,1,"b13-2cols-with-header-container",,,,,, ,201,1,"header","header-live",0,0,0,, -,202,1,"header","header-ws",200,200,1,201,0 \ No newline at end of file +,202,1,"header","header-ws",200,200,1,201,4 \ No newline at end of file diff --git a/Tests/Unit/Domain/Factory/PageView/ContainerFactoryTest.php b/Tests/Unit/Domain/Factory/PageView/Backend/ContainerFactoryTest.php similarity index 77% rename from Tests/Unit/Domain/Factory/PageView/ContainerFactoryTest.php rename to Tests/Unit/Domain/Factory/PageView/Backend/ContainerFactoryTest.php index 2111280e..a517ff41 100644 --- a/Tests/Unit/Domain/Factory/PageView/ContainerFactoryTest.php +++ b/Tests/Unit/Domain/Factory/PageView/Backend/ContainerFactoryTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace B13\Container\Tests\Unit\Domain\Factory\PageView; +namespace B13\Container\Tests\Unit\Domain\Factory\PageView\Backend; /* * This file is part of TYPO3 CMS-based extension "container" by b13. @@ -13,7 +13,8 @@ */ use B13\Container\Domain\Factory\Database; -use B13\Container\Domain\Factory\PageView\ContainerFactory; +use B13\Container\Domain\Factory\PageView\Backend\ContainerFactory; +use B13\Container\Domain\Factory\PageView\Backend\ContentStorage; use B13\Container\Tca\Registry; use TYPO3\CMS\Core\Context\Context; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -34,8 +35,9 @@ public function containerByUidReturnsNullIfNoRecordInDatabaseIsFound(): void $database->expects(self::once())->method('fetchOneRecord')->with(1)->willReturn(null); $tcaRegistry = $this->getMockBuilder(Registry::class)->disableOriginalConstructor()->getMock(); $context = $this->getMockBuilder(Context::class)->getMock(); + $contentStorage = $this->getMockBuilder(ContentStorage::class)->disableOriginalConstructor()->getMock(); $containerFactory = $this->getMockBuilder($this->buildAccessibleProxy(ContainerFactory::class)) - ->setConstructorArgs(['database' => $database, 'tcaRegistry' => $tcaRegistry, 'context' => $context]) + ->setConstructorArgs(['database' => $database, 'tcaRegistry' => $tcaRegistry, 'context' => $context, 'contentStorage' => $contentStorage]) ->onlyMethods([]) ->getMock(); self::assertNull($containerFactory->_call('containerByUid', 1));