From 8dba85b42aef7f27cd99ac6b4d8b0607a27e613c Mon Sep 17 00:00:00 2001 From: Johannes Pieper Date: Thu, 17 Jan 2019 20:19:08 +0100 Subject: [PATCH] Feature-Request #406 a slot to modify forms --- Classes/Service/PageService.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Classes/Service/PageService.php b/Classes/Service/PageService.php index 77fe3651..51c3cdd0 100755 --- a/Classes/Service/PageService.php +++ b/Classes/Service/PageService.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; use TYPO3\CMS\Fluid\View\TemplateView; use TYPO3Fluid\Fluid\View\Exception\InvalidSectionException; @@ -48,6 +49,11 @@ class PageService implements SingletonInterface */ protected $configurationService; + /** + * @var Dispatcher + */ + protected $signalSlotDispatcher = null; + /** * @var WorkspacesAwareRecordService */ @@ -224,6 +230,7 @@ public function getAvailablePageTemplateFiles($format = 'html') try { $view->renderSection('Configuration'); $form = $view->getRenderingContext()->getViewHelperVariableContainer()->get(FormViewHelper::class, 'form'); + $this->emitAfterFormCreate($form, $extensionName); if (false === $form instanceof Form) { $logger->log( @@ -256,4 +263,19 @@ protected function getRuntimeCache() { return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime'); } + + /** + * Emits a signal after a form has been created. + * + * @param Form $form + * @param String $extensionName + */ + protected function emitAfterFormCreate(Form $form, String $extensionName) + { + if ($this->signalSlotDispatcher === null) { + $this->signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class); + } + $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterFormCreate', [$form, $extensionName]); + } + }