Skip to content

Commit

Permalink
[BUGFIX] Fix type Pass value not available in ContentBlockData
Browse files Browse the repository at this point in the history
  • Loading branch information
nhovratov committed Aug 29, 2024
1 parent 1db5b5c commit 84a263e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
8 changes: 7 additions & 1 deletion Classes/DataProcessing/ContentBlockDataDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection;
use TYPO3\CMS\ContentBlocks\Definition\TcaFieldDefinition;
use TYPO3\CMS\ContentBlocks\FieldType\FieldType;
use TYPO3\CMS\ContentBlocks\FieldType\PassFieldType;
use TYPO3\CMS\Core\Collection\LazyRecordCollection;
use TYPO3\CMS\Core\Domain\Record;

Expand Down Expand Up @@ -86,7 +87,12 @@ private function buildContentBlockDataObjectRecursive(
if ($fieldTypeEnum?->isStructureField()) {
continue;
}
$resolvedField = $resolvedRelation->record[$tcaFieldDefinition->getUniqueIdentifier()];
// TCA type "passthrough" is not available in the record, and it won't fall back to raw record value.
if ($fieldType instanceof PassFieldType) {
$resolvedField = $resolvedRelation->record->getRawRecord()[$tcaFieldDefinition->getUniqueIdentifier()];
} else {
$resolvedField = $resolvedRelation->record[$tcaFieldDefinition->getUniqueIdentifier()];
}
if ($this->isRelationField($resolvedField)) {
$resolvedField = $this->handleRelation(
$resolvedField,
Expand Down
31 changes: 15 additions & 16 deletions Tests/Functional/Frontend/ContentBlockFrontendRenderingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,19 @@ public function categoryRelationResolved(): void
self::assertStringContainsString('Category 2', $html);
}

// @todo This needs to be fixed in Core.
// #[Test]
// public function passFieldIsResolved(): void
// {
// $this->importCSVDataSet(__DIR__ . '/Fixtures/DataSet/pass.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('pass: MyPassValue', $html);
// }
#[Test]
public function passFieldIsResolved(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/DataSet/pass.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('pass: MyPassValue', $html);
}
}

0 comments on commit 84a263e

Please sign in to comment.