diff --git a/Classes/DataProcessing/ContentBlockDataDecorator.php b/Classes/DataProcessing/ContentBlockDataDecorator.php
index f71dd1c8..9e41f8c3 100644
--- a/Classes/DataProcessing/ContentBlockDataDecorator.php
+++ b/Classes/DataProcessing/ContentBlockDataDecorator.php
@@ -120,16 +120,14 @@ private function handleRelation(
?PageLayoutContext $context = null,
): mixed {
$resolvedField = $resolvedRelation->resolved[$tcaFieldDefinition->getUniqueIdentifier()];
- $fieldTypeName = $tcaFieldDefinition->getFieldType()->getName();
- $fieldTypeEnum = FieldType::tryFrom($fieldTypeName);
- $resolvedField = match ($fieldTypeEnum) {
- FieldType::COLLECTION,
- FieldType::RELATION => $this->transformMultipleRelation(
+ $fieldType = $tcaFieldDefinition->getFieldType();
+ $resolvedField = match ($fieldType::getTcaType()) {
+ 'inline', 'group', 'category' => $this->transformMultipleRelation(
$resolvedField,
$depth,
$context,
),
- FieldType::SELECT => $this->transformSelectRelation(
+ 'select' => $this->transformSelectRelation(
$resolvedField,
$depth,
$context,
diff --git a/Classes/DataProcessing/RelationResolver.php b/Classes/DataProcessing/RelationResolver.php
index 9fcb396b..9675d95d 100644
--- a/Classes/DataProcessing/RelationResolver.php
+++ b/Classes/DataProcessing/RelationResolver.php
@@ -90,8 +90,8 @@ public function processField(
array $record,
string $table
): mixed {
- $fieldTypeName = $tcaFieldDefinition->getFieldType()->getName();
- $fieldTypeEnum = FieldType::tryFrom($fieldTypeName);
+ $fieldType = $tcaFieldDefinition->getFieldType();
+ $tcaType = $fieldType::getTcaType();
$recordIdentifier = $tcaFieldDefinition->getUniqueIdentifier();
if (!array_key_exists($recordIdentifier, $record)) {
throw new \RuntimeException(
@@ -101,21 +101,21 @@ public function processField(
);
}
$data = $record[$recordIdentifier];
- if ($fieldTypeEnum === FieldType::FILE) {
+ if ($tcaType === 'file') {
$fileCollector = GeneralUtility::makeInstance(FileCollector::class);
$fileCollector->addFilesFromRelation($table, $recordIdentifier, $record);
return $fileCollector->getFiles();
}
- if ($fieldTypeEnum === FieldType::COLLECTION) {
+ if ($tcaType === 'inline') {
return $this->processCollection($table, $record, $tcaFieldDefinition, $typeDefinition);
}
- if ($fieldTypeEnum === FieldType::CATEGORY) {
+ if ($tcaType === 'category') {
return $this->processCategory($tcaFieldDefinition, $typeDefinition, $table, $record);
}
- if ($fieldTypeEnum === FieldType::RELATION) {
+ if ($tcaType === 'group') {
return $this->processRelation($tcaFieldDefinition, $typeDefinition, $table, $record);
}
- if ($fieldTypeEnum === FieldType::FOLDER) {
+ if ($tcaType === 'folder') {
$fileCollector = GeneralUtility::makeInstance(FileCollector::class);
$folders = GeneralUtility::trimExplode(',', (string)$data, true);
/** @var FolderFieldType $folderFieldType */
@@ -123,13 +123,13 @@ public function processField(
$fileCollector->addFilesFromFolders($folders, $folderFieldType->isRecursive());
return $fileCollector->getFiles();
}
- if ($fieldTypeEnum === FieldType::SELECT) {
+ if ($tcaType === 'select') {
return $this->processSelect($tcaFieldDefinition, $typeDefinition, $table, $record);
}
- if ($fieldTypeEnum === FieldType::FLEXFORM) {
+ if ($tcaType === 'flex') {
return $this->flexFormService->convertFlexFormContentToArray($data);
}
- if ($fieldTypeEnum === FieldType::JSON) {
+ if ($tcaType === 'json') {
$platform = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($table)
->getDatabasePlatform();
diff --git a/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/EditorInterface.yaml b/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/EditorInterface.yaml
index 2b4bc417..e63f812e 100644
--- a/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/EditorInterface.yaml
+++ b/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/EditorInterface.yaml
@@ -30,3 +30,5 @@ fields:
type: Select
renderType: selectSingle
foreign_table: tt_content
+ - identifier: categories
+ type: Category
diff --git a/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/Source/Frontend.html b/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/Source/Frontend.html
index 734f54d9..64764872 100644
--- a/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/Source/Frontend.html
+++ b/Tests/Fixtures/Extensions/test_content_blocks_c/ContentBlocks/ContentElements/simple-relation/Source/Frontend.html
@@ -44,3 +44,9 @@
Circular select uid: {data.circular_select.circular_select.uid}
+
+
+ Category table: {category.tableName}
+ {category.title}
+
+
diff --git a/Tests/Functional/Frontend/ContentBlockFrontendRenderingTest.php b/Tests/Functional/Frontend/ContentBlockFrontendRenderingTest.php
index 46eb2312..07ea7d9c 100644
--- a/Tests/Functional/Frontend/ContentBlockFrontendRenderingTest.php
+++ b/Tests/Functional/Frontend/ContentBlockFrontendRenderingTest.php
@@ -258,4 +258,22 @@ public function circularRelationsResolved(): void
self::assertStringContainsString('Circular relation uid: 1', $html);
self::assertStringContainsString('Circular select uid: 1', $html);
}
+
+ #[Test]
+ public function categoryRelationResolved(): void
+ {
+ $this->importCSVDataSet(__DIR__ . '/Fixtures/DataSet/categories.csv');
+ $this->setUpFrontendRootPage(
+ self::ROOT_PAGE_ID,
+ [
+ 'EXT:content_blocks/Tests/Functional/Frontend/Fixtures/frontend.typoscript',
+ ]
+ );
+ $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::ROOT_PAGE_ID));
+ $html = (string)$response->getBody();
+
+ self::assertStringContainsString('Category table: sys_category', $html);
+ self::assertStringContainsString('Category 1', $html);
+ self::assertStringContainsString('Category 2', $html);
+ }
}
diff --git a/Tests/Functional/Frontend/Fixtures/DataSet/categories.csv b/Tests/Functional/Frontend/Fixtures/DataSet/categories.csv
new file mode 100644
index 00000000..1932cd26
--- /dev/null
+++ b/Tests/Functional/Frontend/Fixtures/DataSet/categories.csv
@@ -0,0 +1,14 @@
+"pages"
+,"uid","pid","title","doktype"
+,2,1,"Record Storage",254
+"sys_category"
+,"uid","pid","title"
+,1,2,"Category 1"
+,2,2,"Category 2"
+"sys_category_record_mm"
+,"uid_local","uid_foreign","tablenames","fieldname"
+,1,1,"tt_content","simple_simplerelation_categories"
+,2,1,"tt_content","simple_simplerelation_categories"
+"tt_content"
+,"uid","pid","t3ver_oid","t3ver_wsid","simple_simplerelation_categories","CType"
+,1,1,0,0,"2","simple_simplerelation"