Skip to content

Commit

Permalink
[TASK] Extend RenderBlockViewHelper to resolve dataProcessors
Browse files Browse the repository at this point in the history
  • Loading branch information
o-ba committed Apr 12, 2024
1 parent 5d6e038 commit e69bcee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
15 changes: 14 additions & 1 deletion local_packages/psi/Classes/ViewHelpers/RenderBlockViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
namespace Jacuzzi\Psi\ViewHelpers;

use Jacuzzi\Psi\Domain\RecordInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper;
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
Expand Down Expand Up @@ -64,7 +66,18 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$subView->assign('rawData', $block->getRecord()->getRawRecord()->toArray());
$subView->assign('context', $context);
try {

$request = $renderingContext->getRequest() ?? $GLOBALS['TYPO3_REQUEST'] ?? null;
if ($request instanceof ServerRequestInterface) {
$elementConfig = $request->getAttribute('frontend.typoscript')?->getSetupArray()['tt_content.'][str_replace('content.', '', $block->getFullType()) . '.'] ?? null;
if (is_array($elementConfig) && $elementConfig !== []) {
$processed = GeneralUtility::makeInstance(ContentDataProcessor::class)->process(
$request->getAttribute('currentContentObject'),
$elementConfig,
['data' => $block->getRecord()->getRawRecord()->toArray()]
);
$subView->assign('data', array_replace_recursive(['data' => $block->toArray(true)], $processed));
}
}
$content = $subView->render();
} catch (InvalidTemplateResourceException) {
// Render via TypoScript as fallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@ lib.contentElement {
0 = EXT:psi/Resources/Private/Templates/Layouts/
}
}

tt_content.menu_subpages.dataProcessing {
10 = menu
10 {
special = directory
special.value.field = pages
dataProcessing {
10 = files
10.references.fieldName = media
}
}
}


0 comments on commit e69bcee

Please sign in to comment.