diff --git a/Classes/Controller/LayoutModuleEditController.php b/Classes/Controller/LayoutModuleEditController.php deleted file mode 100644 index 13eba94..0000000 --- a/Classes/Controller/LayoutModuleEditController.php +++ /dev/null @@ -1,40 +0,0 @@ -getParsedBody()['data'] ?? []; - $cmd = $request->getParsedBody()['cmd'] ?? []; - - if(!empty($data) || !empty($cmd)) { - /** @var DataHandler $dataHandler */ - $dataHandler = GeneralUtility::makeInstance(DataHandler::class); - $dataHandler->start($data, $cmd); - $dataHandler->process_datamap(); - $dataHandler->process_cmdmap(); - } - - return new RedirectResponse($request->getQueryParams()['returnUrl']); - } -} diff --git a/Classes/EventListener/NewsLayoutListener.php b/Classes/EventListener/NewsLayoutListener.php index 3f6ed01..9e0be8a 100644 --- a/Classes/EventListener/NewsLayoutListener.php +++ b/Classes/EventListener/NewsLayoutListener.php @@ -36,10 +36,14 @@ final class NewsLayoutListener { + const DOKTYPE_NEWSPAGE = 24; + public function __construct( protected readonly PageRenderer $pageRenderer, protected readonly IconFactory $iconFactory, - protected readonly ExtensionConfiguration $extensionConfiguration + protected readonly ExtensionConfiguration $extensionConfiguration, + protected readonly NodeFactory $nodeFactory, + protected readonly UriBuilder $uriBuilder, ) {} public function __invoke(ModifyPageLayoutContentEvent $event): void @@ -55,17 +59,19 @@ public function __invoke(ModifyPageLayoutContentEvent $event): void $pageInfo = BackendUtility::readPageAccess($pageId, $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)); // Display page property inline edit only for doktype=24 and function=1 (layout mode) - if($function !== 1 || $pageInfo['doktype'] !== 24 || !$this->isPageEditable($language, $pageInfo)) { + if($function !== 1 || $pageInfo['doktype'] !== self::DOKTYPE_NEWSPAGE || !$this->isPageEditable($language, $pageInfo)) { return; } - /** @var NodeFactory $nodeFactory */ - $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class); $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class); $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class); if ($language > 0) { $overlayRecord = $this->getLocalizedPageRecord($language, $pageId); + if ($overlayRecord === null) { + return; + } + $pageId = $overlayRecord['uid']; } @@ -77,27 +83,24 @@ public function __invoke(ModifyPageLayoutContentEvent $event): void ]; // Render only the palette "tx_newspage_layout" in page layout view: - $GLOBALS['TCA']['pages']['types']['24']['showitem'] = '--palette--;;tx_newspage_layout'; + $GLOBALS['TCA']['pages']['types'][self::DOKTYPE_NEWSPAGE]['showitem'] = '--palette--;;tx_newspage_layout'; $formData = $formDataCompiler->compile($formDataCompilerInput); $formData['renderType'] = 'fullRecordContainer'; - $formResult = $nodeFactory->create($formData)->render(); + $formResult = $this->nodeFactory->create($formData)->render(); $formResultCompiler->mergeResult($formResult); $formResultCompiler->printNeededJSFunctions(); - $params = [ - 'returnUrl' => $event->getRequest()->getAttribute('normalizedParams')->getRequestUri(), + $editUri = (string)$this->uriBuilder->buildUriFromRoute('tce_db', [ 'edit' => [ 'pages' => [ $pageId => 'edit', ], ], - ]; + 'redirect' => $event->getRequest()->getAttribute('normalizedParams')->getRequestUri(), + ]); - /** @var UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); - $editUri = (string)$uriBuilder->buildUriFromRoute('newspage_layout_edit', $params); $this->registerDocHeaderButtons($event->getModuleTemplate()); $formContent = ' diff --git a/Configuration/Backend/Routes.php b/Configuration/Backend/Routes.php deleted file mode 100644 index d1dd196..0000000 --- a/Configuration/Backend/Routes.php +++ /dev/null @@ -1,9 +0,0 @@ - [ - 'path' => '/newspage-layout-edit', - 'access' => 'public', - 'target' => \B13\Newspage\Controller\LayoutModuleEditController::class . '::handle', - ], -]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 8dc9cce..2077395 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -12,14 +12,13 @@ services: public: true B13\Newspage\Filter\CategoriesFilter: public: true - B13\Newspage\Controller\LayoutModuleEditController: - public: true B13\Newspage\EventListener\SimplePaginationProvider: tags: - name: event.listener identifier: 'ext-newspage-simplePaginationProvider' event: B13\Newspage\Event\CreatingPaginationEvent + B13\Newspage\EventListener\NewsLayoutListener: tags: - name: event.listener