Skip to content

Commit

Permalink
Feature-Request FluidTYPO3#406 a slot to modify forms
Browse files Browse the repository at this point in the history
  • Loading branch information
joneppie committed Jan 17, 2019
1 parent 1d090ea commit 8dba85b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Classes/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -48,6 +49,11 @@ class PageService implements SingletonInterface
*/
protected $configurationService;

/**
* @var Dispatcher
*/
protected $signalSlotDispatcher = null;

/**
* @var WorkspacesAwareRecordService
*/
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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]);
}

}

0 comments on commit 8dba85b

Please sign in to comment.