Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature-Request #406 a slot to modify forms #407

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Feature-Request #406 a slot to modify forms
  • Loading branch information
joneppie committed Jan 17, 2019
commit 8dba85b42aef7f27cd99ac6b4d8b0607a27e613c
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]);
}

}