Skip to content

Commit

Permalink
change javascript registration within backend scope to page renderer …
Browse files Browse the repository at this point in the history
…hook
  • Loading branch information
devtroll authored and wazum committed Sep 11, 2022
1 parent fb4aae9 commit e9c7222
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions Classes/Backend/Hook/PageRendererRenderPreProcess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Wazum\Sluggi\Backend\Hook;

use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class PageRendererRenderPreProcess
*
* @author Wolfgang Klinger <wolfgang@wazum.com>
*/
final class PageRendererRenderPreProcess
{
public function addRequireJsConfiguration(array $params, PageRenderer $pageRenderer): void
{
if ($pageRenderer->getApplicationType() === 'BE') {
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Sluggi/Sluggi');
}
}
}
6 changes: 3 additions & 3 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
'priority' => 40,
'class' => \Wazum\Sluggi\Backend\Form\InputTextWithSlugImpactElement::class
];
/** @var \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer */
$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Sluggi/Sluggi');

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['sluggi']
= \Wazum\Sluggi\Backend\Hook\DataHandlerSlugUpdateHook::class;
Expand All @@ -24,6 +21,9 @@
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][]
= \Wazum\Sluggi\Backend\Hook\CommandMapHook::class;

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'][]
= \Wazum\Sluggi\Backend\Hook\PageRendererRenderPreProcess::class . '->addRequireJsConfiguration';

// Add a custom handler without injecting the JavaScript module (already loaded by DispatchNotificationHook (see below)
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php']['constructPostProcess'] as $key => $handler) {
if ($handler === \TYPO3\CMS\Redirects\Hooks\BackendControllerHook::class . '->registerClientSideEventHandler') {
Expand Down

0 comments on commit e9c7222

Please sign in to comment.