Skip to content

Commit

Permalink
[WIP] backend template
Browse files Browse the repository at this point in the history
  • Loading branch information
achimfritz committed Jan 29, 2025
1 parent 749ccf7 commit d588f43
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
39 changes: 39 additions & 0 deletions Classes/Listener/PageContentPreviewRendering.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace B13\Container\Listener;

/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/

use B13\Container\Backend\Preview\GridRenderer;
use B13\Container\Tca\Registry;
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent;

class PageContentPreviewRendering
{
protected GridRenderer $gridRenderer;
protected Registry $tcaRegistry;

public function __construct(GridRenderer $gridRenderer, Registry $tcaRegistry)
{
$this->gridRenderer = $gridRenderer;
$this->tcaRegistry = $tcaRegistry;
}

public function __invoke(PageContentPreviewRenderingEvent $event): void
{
$record = $event->getRecord();
if (!$this->tcaRegistry->isContainerElement($record['CType'])) {
return;
}
$record['tx_container_grid'] = $this->gridRenderer->renderGrid($record, $event->getPageLayoutContext());
$event->setRecord($record);
}
}
4 changes: 3 additions & 1 deletion Classes/Tca/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function configureContainer(ContainerConfiguration $containerConfiguratio
);
}

$GLOBALS['TCA']['tt_content']['types'][$containerConfiguration->getCType()]['previewRenderer'] = \B13\Container\Backend\Preview\ContainerPreviewRenderer::class;
if ($containerConfiguration->getBackendTemplate() === null || (GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) {
$GLOBALS['TCA']['tt_content']['types'][$containerConfiguration->getCType()]['previewRenderer'] = \B13\Container\Backend\Preview\ContainerPreviewRenderer::class;
}

if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 13) {
if (!isset($GLOBALS['TCA']['tt_content']['types'][$containerConfiguration->getCType()]['creationOptions'])) {
Expand Down
5 changes: 5 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ services:
tags:
- name: event.listener
identifier: 'tx-container-boot-completed'
B13\Container\Listener\PageContentPreviewRendering:
tags:
- name: event.listener
identifier: 'tx-container-page-content-preview-rendering'
before: 'typo3-backend/fluid-preview/content'
B13\Container\Command\FixLanguageModeCommand:
tags:
- name: 'console.command'
Expand Down

0 comments on commit d588f43

Please sign in to comment.