Add Container Options

This commit is contained in:
orasche committed 2026-08-14 10:36:36 +02:00
1 parent f515de54ad
commit c720696781
23 files changed
+584 -22

No files matched your search

@@ -14,6 +14,7 @@ use TYPO3\CMS\Core\Service\FlexFormService;
use Evomedien\Vitec\Service\RteResolver;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Service\ImageService;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* Headless JSON renderer for EXT:news content elements.
@@ -25,6 +26,21 @@ use TYPO3\CMS\Extbase\Service\ImageService;
*/
final class NewsJsonRenderer
{
private ?ContentObjectRenderer $cObj = null;
/**
* TYPO3 v14 hands the ContentObjectRenderer over through this setter only -
* ContentObjectRenderer::callUserFunction() duck-types it with
* is_callable([$classObj, 'setContentObjectRenderer']). Without the method
* $this->cObj stays null, the cObj branch of render() never fires and the
* call falls through to page discovery, which picks the FIRST element of
* this CType on the page rather than the one actually being rendered.
*/
public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
{
$this->cObj = $cObj;
}
private const NEWS_CTYPES = [
'news_pi1',
'news_newsliststicky',
@@ -60,7 +76,7 @@ final class NewsJsonRenderer
public function render(string $content, array $conf): string
{
try {
$row = is_array($this->cObj->data ?? null) ? $this->cObj->data : null;
$row = is_array($this->cObj?->data ?? null) ? $this->cObj->data : null;
if ($row !== null && in_array((string)($row['CType'] ?? ''), self::NEWS_CTYPES, true)) {
return $this->renderForRecord($row);
}