From a67d099c10764815d541c0548aaae9933f011f53 Mon Sep 17 00:00:00 2001 From: Justus Moroni <5197489+justusmoroni@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:10:45 +0200 Subject: [PATCH] feat: Detect containers by searching the registry (#19) Before we checked if a CType contained a specific string to check if it is a container. This was open to false positives if a normal content element also contained this string. We now check the proper place to detect if a CType is registered as a container. Related: #6 Co-authored-by: Justus Moroni --- Classes/Sizes/Rootline.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Classes/Sizes/Rootline.php b/Classes/Sizes/Rootline.php index 5fe8967..cf5613a 100644 --- a/Classes/Sizes/Rootline.php +++ b/Classes/Sizes/Rootline.php @@ -23,6 +23,7 @@ * 02110-1301, USA. */ +use B13\Container\Tca\Registry; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; @@ -83,7 +84,10 @@ private function determineBackendLayout(): void private function determineContentElement(array $data): ContentElementInterface { - if (str_contains((string) $data['CType'], '_container-')) { + if ( + class_exists(Registry::class) + && GeneralUtility::makeInstance(Registry::class)->isContainerElement($data['CType']) + ) { return new Container($data); }