Skip to content

Commit

Permalink
feat: Detect containers by searching the registry
Browse files Browse the repository at this point in the history
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
  • Loading branch information
justusmoroni committed Apr 3, 2024
1 parent 6ac5225 commit ead5357
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Classes/Sizes/Rootline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit ead5357

Please sign in to comment.