Skip to content

Commit

Permalink
[TASK] Cleanup event listener and use SimpleDataHandlerController
Browse files Browse the repository at this point in the history
Related: #UKHSD-1184
  • Loading branch information
ochorocho committed Feb 11, 2024
1 parent bb53cdb commit 72c2b5d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 63 deletions.
40 changes: 0 additions & 40 deletions Classes/Controller/LayoutModuleEditController.php

This file was deleted.

27 changes: 15 additions & 12 deletions Classes/EventListener/NewsLayoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'];
}

Expand All @@ -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 = '
Expand Down
9 changes: 0 additions & 9 deletions Configuration/Backend/Routes.php

This file was deleted.

3 changes: 1 addition & 2 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 72c2b5d

Please sign in to comment.