[FOLLOWUP][TASK] EXT:form - change signal slots to hooks 88/52088/10
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Fri, 17 Mar 2017 16:46:07 +0000 (17:46 +0100)
committerBenni Mack <benni@typo3.org>
Wed, 22 Mar 2017 07:44:15 +0000 (08:44 +0100)
Resolves: #80333
Releases: master
Change-Id: I201392bc67228864e31d9e7117880fbb401af279
Reviewed-on: https://review.typo3.org/52088
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Jurian Janssen <jurian.janssen@gmail.com>
Reviewed-by: Ralf Zimmermann <ralf.zimmermann@tritum.de>
Tested-by: Ralf Zimmermann <ralf.zimmermann@tritum.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
15 files changed:
typo3/sysext/core/Documentation/Changelog/master/Important-80301-ExtFormCleanupAndCallbackMigration.rst
typo3/sysext/form/Classes/Controller/FormEditorController.php
typo3/sysext/form/Classes/Controller/FormManagerController.php
typo3/sysext/form/Classes/Domain/Factory/AbstractFormFactory.php
typo3/sysext/form/Classes/Domain/Model/FormElements/AbstractFormElement.php
typo3/sysext/form/Classes/Domain/Model/FormElements/Section.php
typo3/sysext/form/Classes/Domain/Model/FormElements/UnknownFormElement.php
typo3/sysext/form/Classes/Domain/Model/Renderable/AbstractRenderable.php
typo3/sysext/form/Classes/Domain/Renderer/FluidFormRenderer.php
typo3/sysext/form/Classes/Domain/Renderer/RendererInterface.php
typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php
typo3/sysext/form/Classes/Hooks/FormElementsOnSubmitHooks.php
typo3/sysext/form/Classes/Mvc/Property/PropertyMappingConfiguration.php
typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php
typo3/sysext/form/ext_localconf.php

index bca2cc5..be7e3ff 100644 (file)
@@ -12,20 +12,16 @@ Description
 The callback 'onBuildingFinished' is deprecated and will be removed in TYPO3 v9.
 --------------------------------------------------------------------------------
 
-Use the new signal slot 'onBuildingFinished' instead.
+Use the new hook 'afterBuildingFinished' instead.
 
-Connect to the signal:
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
-        'onBuildingFinished',
-        \VENDOR\YourNamespace\YourClass::class,
-        'onBuildingFinished'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterBuildingFinished'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Use the signal:
+Use the hook:
 
 .. code-block:: php
 
@@ -33,29 +29,25 @@ Use the signal:
      * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
      * @return void
      */
-    public function onBuildingFinished(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
+    public function afterBuildingFinished(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
     {
     }
 
 
-This signal will be dispatched for each renderable.
+This hook will be called for each renderable.
 
 
 The callback 'beforeRendering' is deprecated and will be removed in TYPO3 v9.
 -----------------------------------------------------------------------------
 
-Use the new signal slot 'beforeRendering' instead.
+Use the new hook 'beforeRendering' instead.
 
-Connect to the signal:
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
-        'beforeRendering',
-        \VENDOR\YourNamespace\YourClass::class,
-        'beforeRendering'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
 Use the signal:
 
@@ -71,59 +63,52 @@ Use the signal:
     }
 
 
-This signal will be dispatched for each renderable.
+This hook will be called for each renderable.
 
 
 The callback 'onSubmit' is deprecated and will be removed in TYPO3 v9.
 ----------------------------------------------------------------------
 
-Use the new signal slot 'onSubmit' instead.
+Use the new hook 'afterSubmit' instead.
 
-Connect to the signal:
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
-        'onSubmit',
-        \VENDOR\YourNamespace\YourClass::class,
-        'onSubmit'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Use the signal:
+Use the hook:
 
 .. code-block:: php
 
     /**
      * @param \TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime
      * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
-     * @param mixed &$elementValue submitted value of the element *before post processing*
+     * @param mixed $elementValue submitted value of the element *before post processing*
      * @param array $requestArguments submitted raw request values
      * @return void
      */
-    public function onSubmit(\TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime, \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable, &$elementValue, array $requestArguments = [])
+    public function onSubmit(\TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime, \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable, $elementValue, array $requestArguments = [])
     {
+        return $elementValue;
     }
 
 
-This signal will be dispatched for each renderable.
+This hook will be called for each renderable.
 
 
-The callback 'initializeFormElement' dispatches the 'initializeFormElement' signal.
------------------------------------------------------------------------------------
+The callback 'initializeFormElement' call the 'initializeFormElement' hook.
+---------------------------------------------------------------------------
 
-Connect to the signal:
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable::class,
-        'initializeFormElement',
-        \VENDOR\YourNamespace\YourClass::class,
-        'initializeFormElement'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Use the signal:
+Use the hook:
 
 .. code-block:: php
 
@@ -137,127 +122,165 @@ Use the signal:
 
 
 This enables you to override the 'initializeFormElement' method within your custom implementation class.
-If you do not call the parents 'initializeFormElement' then no signal will be thrown.
-Furthermore, you can connect to the signal and initialize the generic form elements without defining a
+If you do not call the parents 'initializeFormElement' then no hook will be thrown.
+Furthermore, you can connect to the hook and initialize the generic form elements without defining a
 custom implementaion to access the 'initializeFormElement' method.
-You only need a class which connects to this signal. Then detect the form element you wish to initialize.
+You only need a class which connects to this hook. Then detect the form element you wish to initialize.
 This saves you a lot of configuration!
 
 
-The form manager dispatches the 'beforeFormCreate' signal.
-----------------------------------------------------------
+The hook 'beforeRemoveFromParentRenderable' will be called for each renderable.
+-------------------------------------------------------------------------------
 
-Connect to the signal:
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Controller\FormManagerController::class,
-        'beforeFormCreate',
-        \VENDOR\YourNamespace\YourClass::class,
-        'beforeFormCreate'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRemoveFromParentRenderable'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Use the signal:
+Use the hook:
 
 .. code-block:: php
 
     /**
-     * @string $formPersistenceIdentifier
-     * @array $formDefinition
+     * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
      * @return void
      */
-    public function beforeFormCreate(string $formPersistenceIdentifier, array &$formDefinition)
+    public function beforeRemoveFromParentRenderable(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
     {
     }
 
 
-The form manager dispatches the 'beforeFormDuplicate' signal.
--------------------------------------------------------------
+The hook 'afterInitializeCurrentPage' will be called after a page is initialized.
+---------------------------------------------------------------------------------
 
-Connect to the signal:
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Controller\FormManagerController::class,
-        'beforeFormDuplicate',
-        \VENDOR\YourNamespace\YourClass::class,
-        'beforeFormDuplicate'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Use the signal:
+Use the hook:
 
 .. code-block:: php
 
     /**
-     * @string $formPersistenceIdentifier
-     * @array $formDefinition
-     * @return void
+     * @param \TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime
+     * @param \TYPO3\CMS\Form\Domain\Model\Renderable\CompositeRenderableInterface $currentPage
+     * @param null|\TYPO3\CMS\Form\Domain\Model\Renderable\CompositeRenderableInterface $lastPage
+     * @param mixed $elementValue submitted value of the element *before post processing*
+     * @return \TYPO3\CMS\Form\Domain\Model\Renderable\CompositeRenderableInterface
      */
-    public function beforeFormDuplicate(string $formPersistenceIdentifier, array &$formDefinition)
+    public function afterInitializeCurrentPage(\TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime, \TYPO3\CMS\Form\Domain\Model\Renderable\CompositeRenderableInterface $currentPage, \TYPO3\CMS\Form\Domain\Model\Renderable\CompositeRenderableInterface $lastPage = null, array $requestArguments = []): CompositeRenderableInterface
     {
+        return $currentPage;
     }
 
 
-The form manager dispatches the 'beforeFormDelete' signal.
-----------------------------------------------------------
+The form manager call the 'beforeFormCreate' hook.
+--------------------------------------------------
+
+Connect to the hook:
+
+.. code-block:: php
+
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormCreate'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Connect to the signal:
+Use the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Controller\FormManagerController::class,
-        'beforeFormDelete',
-        \VENDOR\YourNamespace\YourClass::class,
-        'beforeFormDelete'
-    );
+    /**
+     * @param string $formPersistenceIdentifier
+     * @param array $formDefinition
+     * @return array
+     */
+    public function beforeFormCreate(string $formPersistenceIdentifier, array $formDefinition): array
+    {
+        return $formDefinition;
+    }
+
+
+The form manager call the 'beforeFormDuplicate' hook.
+-----------------------------------------------------
+
+Connect to the hook:
+
+.. code-block:: php
+
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDuplicate'][]
+        = \VENDOR\YourNamespace\YourClass::class;
+
+Use the hook:
+
+.. code-block:: php
+
+    /**
+     * @param string $formPersistenceIdentifier
+     * @param array $formDefinition
+     * @return array
+     */
+    public function beforeFormDuplicate(string $formPersistenceIdentifier, array $formDefinition): array
+    {
+        return $formDefinition;
+    }
+
+
+The form manager call the 'beforeFormDelete' hook.
+--------------------------------------------------
+
+Connect to the hook:
+
+.. code-block:: php
+
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDelete'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
 Use the signal:
 
 .. code-block:: php
 
     /**
-     * @string $formPersistenceIdentifier
+     * @param string $formPersistenceIdentifier
      * @return void
      */
     public function beforeFormDelete(string $formPersistenceIdentifier)
     {
     }
 
-The form editor dispatches the 'beforeFormSave' signal.
--------------------------------------------------------
 
-Connect to the signal:
+The form editor call the 'beforeFormSave' hook.
+-----------------------------------------------
+
+Connect to the hook:
 
 .. code-block:: php
 
-    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-        \TYPO3\CMS\Form\Controller\FormEditorController::class,
-        'beforeFormSave',
-        \VENDOR\YourNamespace\YourClass::class,
-        'beforeFormSave'
-    );
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormSave'][]
+        = \VENDOR\YourNamespace\YourClass::class;
 
-Use the signal:
+Use the hook:
 
 .. code-block:: php
 
     /**
-     * @string $formPersistenceIdentifier
-     * @array $formDefinition
-     * @return void
+     * @param string $formPersistenceIdentifier
+     * @param array $formDefinition
+     * @return array
      */
-    public function beforeFormSave(string $formPersistenceIdentifier, array &$formDefinition)
+    public function beforeFormSave(string $formPersistenceIdentifier, array $formDefinition): array
     {
+        return $formDefinition;
     }
 
 
 New form element property: properties.fluidAdditionalAttributes
 ---------------------------------------------------------------
 
-To deal with fluid ViewHelpers 'additionalAttributes' it is necessary to introduce a new configuration scope "properties.fluidAdditionalAttributes" for each form element.
+In order to deal with fluid ViewHelpers 'additionalAttributes' it is necessary to introduce a new configuration scope "properties.fluidAdditionalAttributes" for each form element.
 This configuration property will be used to fill the fluid ViewHelper property "additionalAttributes".
 
 
index c1a1a18..b991851 100644 (file)
@@ -22,7 +22,6 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Fluid\View\TemplateView;
 use TYPO3\CMS\Form\Domain\Configuration\ConfigurationService;
 use TYPO3\CMS\Form\Domain\Exception\RenderingException;
@@ -144,13 +143,20 @@ class FormEditorController extends AbstractBackendController
         $formDefinition = ArrayUtility::stripTagsFromValuesRecursive($formDefinition);
         $formDefinition = $this->convertJsonArrayToAssociativeArray($formDefinition);
 
-        $this->objectManager
-            ->get(Dispatcher::class)
-            ->dispatch(
-                self::class,
-                'beforeFormSave',
-                [$formPersistenceIdentifier, &$formDefinition]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormSave'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormSave'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormSave'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'beforeFormSave')) {
+                    $formDefinition = $hookObj->beforeFormSave(
+                        $formPersistenceIdentifier,
+                        $formDefinition
+                    );
+                }
+            }
+        }
 
         $this->formPersistenceManager->save($formPersistenceIdentifier, $formDefinition);
         return '';
index edfc07a..9c155b5 100644 (file)
@@ -28,7 +28,6 @@ use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Mvc\View\JsonView;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Form\Exception as FormException;
 use TYPO3\CMS\Form\Service\TranslationService;
 use TYPO3\CMS\Lang\LanguageService;
@@ -109,13 +108,20 @@ class FormManagerController extends AbstractBackendController
 
         $formPersistenceIdentifier = $this->formPersistenceManager->getUniquePersistenceIdentifier($form['identifier'], $savePath);
 
-        $this->objectManager
-            ->get(Dispatcher::class)
-            ->dispatch(
-                self::class,
-                'beforeFormCreate',
-                [$formPersistenceIdentifier, &$form]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormCreate'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormCreate'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormCreate'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'beforeFormCreate')) {
+                    $form = $hookObj->beforeFormCreate(
+                        $formPersistenceIdentifier,
+                        $form
+                    );
+                }
+            }
+        }
 
         $this->formPersistenceManager->save($formPersistenceIdentifier, $form);
 
@@ -139,13 +145,20 @@ class FormManagerController extends AbstractBackendController
 
         $formPersistenceIdentifier = $this->formPersistenceManager->getUniquePersistenceIdentifier($formToDuplicate['identifier'], $savePath);
 
-        $this->objectManager
-            ->get(Dispatcher::class)
-            ->dispatch(
-                self::class,
-                'beforeFormDuplicate',
-                [$formPersistenceIdentifier, &$formToDuplicate]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDuplicate'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDuplicate'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDuplicate'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'beforeFormDuplicate')) {
+                    $formToDuplicate = $hookObj->beforeFormDuplicate(
+                        $formPersistenceIdentifier,
+                        $formToDuplicate
+                    );
+                }
+            }
+        }
 
         $this->formPersistenceManager->save($formPersistenceIdentifier, $formToDuplicate);
 
@@ -181,13 +194,19 @@ class FormManagerController extends AbstractBackendController
     public function deleteAction(string $formPersistenceIdentifier)
     {
         if (empty($this->getReferences($formPersistenceIdentifier))) {
-            $this->objectManager
-                ->get(Dispatcher::class)
-                ->dispatch(
-                    self::class,
-                    'beforeFormDelete',
-                    [$formPersistenceIdentifier]
-                );
+            if (
+                isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDelete'])
+                && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDelete'])
+            ) {
+                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDelete'] as $className) {
+                    $hookObj = GeneralUtility::makeInstance($className);
+                    if (method_exists($hookObj, 'beforeFormDelete')) {
+                        $hookObj->beforeFormDelete(
+                            $formPersistenceIdentifier
+                        );
+                    }
+                }
+            }
 
             $this->formPersistenceManager->delete($formPersistenceIdentifier);
         } else {
index 2ac4939..23b0e42 100644 (file)
@@ -19,9 +19,7 @@ namespace TYPO3\CMS\Form\Domain\Factory;
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
-use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
 
 /**
  * Base class for custom *Form Factories*. A Form Factory is responsible for building
@@ -55,8 +53,8 @@ use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
 abstract class AbstractFormFactory implements FormFactoryInterface
 {
     /**
-     * Helper to be called by every AbstractFormFactory after everything has been built to dispatch the "onBuildingFinished"
-     * signal on all form elements.
+     * Helper to be called by every AbstractFormFactory after everything has been built to call the "afterBuildingFinished"
+     * hook on all form elements.
      *
      * @param FormDefinition $form
      * @return void
@@ -68,13 +66,19 @@ abstract class AbstractFormFactory implements FormFactoryInterface
             GeneralUtility::deprecationLog('EXT:form - calls for "onBuildingFinished" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
             $renderable->onBuildingFinished();
 
-            GeneralUtility::makeInstance(ObjectManager::class)
-                ->get(Dispatcher::class)
-                ->dispatch(
-                    FormRuntime::class,
-                    'onBuildingFinished',
-                    [$renderable]
-                );
+            if (
+                isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterBuildingFinished'])
+                && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterBuildingFinished'])
+            ) {
+                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterBuildingFinished'] as $className) {
+                    $hookObj = GeneralUtility::makeInstance($className);
+                    if (method_exists($hookObj, 'afterBuildingFinished')) {
+                        $hookObj->afterBuildingFinished(
+                            $renderable
+                        );
+                    }
+                }
+            }
         }
     }
 }
index 63a493f..43cc590 100644 (file)
@@ -18,8 +18,6 @@ namespace TYPO3\CMS\Form\Domain\Model\FormElements;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator;
 use TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException;
 use TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable;
@@ -77,13 +75,19 @@ abstract class AbstractFormElement extends AbstractRenderable implements FormEle
      */
     public function initializeFormElement()
     {
-        GeneralUtility::makeInstance(ObjectManager::class)
-            ->get(Dispatcher::class)
-            ->dispatch(
-                AbstractRenderable::class,
-                'initializeFormElement',
-                [$this]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'initializeFormElement')) {
+                    $hookObj->initializeFormElement(
+                        $this
+                    );
+                }
+            }
+        }
     }
 
     /**
index 0b6b140..3522334 100644 (file)
@@ -18,11 +18,8 @@ namespace TYPO3\CMS\Form\Domain\Model\FormElements;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator;
 use TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface;
-use TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable;
 
 /**
  * A Section, being part of a bigger Page
@@ -51,13 +48,19 @@ class Section extends AbstractSection implements FormElementInterface
      */
     public function initializeFormElement()
     {
-        GeneralUtility::makeInstance(ObjectManager::class)
-            ->get(Dispatcher::class)
-            ->dispatch(
-                AbstractRenderable::class,
-                'initializeFormElement',
-                [$this]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'initializeFormElement')) {
+                    $hookObj->initializeFormElement(
+                        $this
+                    );
+                }
+            }
+        }
     }
 
     /**
index ed1c3d9..465e4f2 100644 (file)
@@ -18,8 +18,6 @@ namespace TYPO3\CMS\Form\Domain\Model\FormElements;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException;
 use TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable;
 use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
@@ -55,13 +53,19 @@ class UnknownFormElement extends AbstractRenderable implements FormElementInterf
      */
     public function initializeFormElement()
     {
-        GeneralUtility::makeInstance(ObjectManager::class)
-            ->get(Dispatcher::class)
-            ->dispatch(
-                AbstractRenderable::class,
-                'initializeFormElement',
-                [$this]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'initializeFormElement')) {
+                    $hookObj->initializeFormElement(
+                        $this
+                    );
+                }
+            }
+        }
     }
 
     /**
index 9aa876d..9a15697 100644 (file)
@@ -345,6 +345,20 @@ abstract class AbstractRenderable implements RenderableInterface
      */
     public function onRemoveFromParentRenderable()
     {
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRemoveFromParentRenderable'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRemoveFromParentRenderable'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRemoveFromParentRenderable'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'beforeRemoveFromParentRenderable')) {
+                    $hookObj->beforeRemoveFromParentRenderable(
+                        $this
+                    );
+                }
+            }
+        }
+
         try {
             $rootForm = $this->getRootForm();
             $rootForm->unregisterRenderable($this);
index 1d2487e..7236832 100644 (file)
@@ -19,7 +19,6 @@ namespace TYPO3\CMS\Form\Domain\Renderer;
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Fluid\View\TemplateView;
 use TYPO3\CMS\Form\Domain\Exception\RenderingException;
 use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
@@ -128,10 +127,10 @@ class FluidFormRenderer extends AbstractElementRenderer implements RendererInter
     /**
      * Renders the FormDefinition.
      *
-     * This method is expected to dispatch the 'beforeRendering' signal
+     * This method is expected to call the 'beforeRendering' hook
      * on each renderable.
-     * This method dispatch the 'beforeRendering' signal initially.
-     * Each other signals will be dispatched from the
+     * This method call the 'beforeRendering' hook initially.
+     * Each other hooks will be called from the
      * renderRenderable viewHelper.
      * {@link \TYPO3\CMS\Form\ViewHelpers\RenderRenderableViewHelper::renderStatic()}
      *
@@ -179,13 +178,20 @@ class FluidFormRenderer extends AbstractElementRenderer implements RendererInter
         GeneralUtility::deprecationLog('EXT:form - calls for "beforeRendering" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
         $this->formRuntime->getFormDefinition()->beforeRendering($this->formRuntime);
 
-        GeneralUtility::makeInstance(ObjectManager::class)
-            ->get(Dispatcher::class)
-            ->dispatch(
-                FormRuntime::class,
-                'beforeRendering',
-                [$this->formRuntime, $this->formRuntime->getFormDefinition()]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'beforeRendering')) {
+                    $hookObj->beforeRendering(
+                        $this->formRuntime,
+                        $this->formRuntime->getFormDefinition()
+                    );
+                }
+            }
+        }
 
         return $view->render($this->formRuntime->getTemplateName());
     }
index 9e12483..50840c3 100644 (file)
@@ -39,7 +39,7 @@ interface RendererInterface
     public function setControllerContext(ControllerContext $controllerContext);
 
     /**
-     * Note: This method is expected to dispatch the 'beforeRendering' signal
+     * Note: This method is expected to call the 'beforeRendering' hook
      * on each $renderable
      *
      * @return string the rendered $formRuntime
index 80cf2c7..cd7a6a3 100644 (file)
@@ -27,7 +27,6 @@ use TYPO3\CMS\Extbase\Mvc\Web\Response;
 use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
 use TYPO3\CMS\Extbase\Property\Exception as PropertyException;
 use TYPO3\CMS\Extbase\Reflection\PropertyReflection;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Form\Domain\Exception\RenderingException;
 use TYPO3\CMS\Form\Domain\Finishers\FinisherContext;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
@@ -208,6 +207,22 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
     {
         if (!$this->formState->isFormSubmitted()) {
             $this->currentPage = $this->formDefinition->getPageByIndex(0);
+            if (
+                isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'])
+                && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'])
+            ) {
+                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'] as $className) {
+                    $hookObj = GeneralUtility::makeInstance($className);
+                    if (method_exists($hookObj, 'afterInitializeCurrentPage')) {
+                        $this->currentPage = $hookObj->afterInitializeCurrentPage(
+                            $this,
+                            $this->currentPage,
+                            null,
+                            $this->request->getArguments()
+                        );
+                    }
+                }
+            }
             return;
         }
         $this->lastDisplayedPage = $this->formDefinition->getPageByIndex($this->formState->getLastDisplayedPageIndex());
@@ -226,6 +241,23 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
         } else {
             $this->currentPage = $this->formDefinition->getPageByIndex($currentPageIndex);
         }
+
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterInitializeCurrentPage'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'afterInitializeCurrentPage')) {
+                    $this->currentPage = $hookObj->afterInitializeCurrentPage(
+                        $this,
+                        $this->currentPage,
+                        $this->lastDisplayedPage,
+                        $this->request->getArguments()
+                    );
+                }
+            }
+        }
     }
 
     /**
@@ -411,13 +443,22 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
         GeneralUtility::deprecationLog('EXT:form - calls for "onSubmit" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
         $page->onSubmit($this, $value, $requestArguments);
 
-        $this->objectManager
-            ->get(Dispatcher::class)
-            ->dispatch(
-                self::class,
-                'onSubmit',
-                [$this, $page, &$value, $requestArguments]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'afterSubmit')) {
+                    $value = $hookObj->afterSubmit(
+                        $this,
+                        $page,
+                        $value,
+                        $requestArguments
+                    );
+                }
+            }
+        }
 
         foreach ($page->getElementsRecursively() as $element) {
             try {
@@ -429,13 +470,22 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
             GeneralUtility::deprecationLog('EXT:form - calls for "onSubmit" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
             $element->onSubmit($this, $value, $requestArguments);
 
-            $this->objectManager
-                ->get(Dispatcher::class)
-                ->dispatch(
-                    self::class,
-                    'onSubmit',
-                    [$this, $element, &$value, $requestArguments]
-                );
+            if (
+                isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'])
+                && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'])
+            ) {
+                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'] as $className) {
+                    $hookObj = GeneralUtility::makeInstance($className);
+                    if (method_exists($hookObj, 'afterSubmit')) {
+                        $value = $hookObj->afterSubmit(
+                            $this,
+                            $element,
+                            $value,
+                            $requestArguments
+                        );
+                    }
+                }
+            }
 
             $this->formState->setFormValue($element->getIdentifier(), $value);
             $registerPropertyPaths($element->getIdentifier());
index b90886c..9e1e104 100644 (file)
@@ -28,18 +28,18 @@ class FormElementsOnSubmitHooks
 {
 
     /**
-     * This signal is invoked by the FormRuntime whenever values are mapped and validated
+     * This hook is invoked by the FormRuntime whenever values are mapped and validated
      * (after a form page was submitted)
      *
      * @param FormRuntime $formRuntime
      * @param RenderableInterface $renderable
-     * @param mixed &$elementValue submitted value of the element *before post processing*
+     * @param mixed $elementValue submitted value of the element *before post processing*
      * @param array $requestArguments submitted raw request values
      * @return void
      * @see FormRuntime::mapAndValidate()
      * @internal
      */
-    public function onSubmit(FormRuntime $formRuntime, RenderableInterface $renderable, &$elementValue, array $requestArguments = [])
+    public function afterSubmit(FormRuntime $formRuntime, RenderableInterface $renderable, $elementValue, array $requestArguments = [])
     {
         if ($renderable->getType() === 'AdvancedPassword') {
             if ($elementValue['password'] !== $elementValue['confirmation']) {
@@ -51,5 +51,7 @@ class FormElementsOnSubmitHooks
             }
             $elementValue = $elementValue['password'];
         }
+
+        return $elementValue;
     }
 }
index ae43b3c..0be6708 100644 (file)
@@ -48,7 +48,7 @@ class PropertyMappingConfiguration
      * @internal
      * @todo: could we find a not so ugly solution for that?
      */
-    public function setPropertyMappingConfiguration(RenderableInterface $renderable)
+    public function afterBuildingFinished(RenderableInterface $renderable)
     {
         if (get_class($renderable) === FileUpload::class) {
             /** @var \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration */
index f489582..c72a909 100644 (file)
@@ -18,7 +18,6 @@ namespace TYPO3\CMS\Form\ViewHelpers;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface;
 use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
@@ -74,14 +73,20 @@ class RenderRenderableViewHelper extends AbstractViewHelper
         GeneralUtility::deprecationLog('EXT:form - calls for "beforeRendering" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
         $arguments['renderable']->beforeRendering($formRuntime);
 
-        $renderingContext
-            ->getObjectManager()
-            ->get(Dispatcher::class)
-            ->dispatch(
-                FormRuntime::class,
-                'beforeRendering',
-                [$formRuntime, $arguments['renderable']]
-            );
+        if (
+            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
+            && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
+        ) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'] as $className) {
+                $hookObj = GeneralUtility::makeInstance($className);
+                if (method_exists($hookObj, 'beforeRendering')) {
+                    $hookObj->beforeRendering(
+                        $formRuntime,
+                        $arguments['renderable']
+                    );
+                }
+            }
+        }
 
         $content = $renderChildrenClosure();
 
index 45c13bd..dc6c251 100644 (file)
@@ -59,20 +59,12 @@ call_user_func(function () {
     }
 
     if (TYPO3_MODE === 'FE') {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-            \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
-            'onSubmit',
-            \TYPO3\CMS\Form\Hooks\FormElementsOnSubmitHooks::class,
-            'onSubmit'
-        );
+        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterSubmit'][1489772699]
+            = \TYPO3\CMS\Form\Hooks\FormElementsOnSubmitHooks::class;
 
         // FE file upload processing
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
-            \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
-            'onBuildingFinished',
-            \TYPO3\CMS\Form\Mvc\Property\PropertyMappingConfiguration::class,
-            'setPropertyMappingConfiguration'
-        );
+        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterBuildingFinished'][1489772699]
+            = \TYPO3\CMS\Form\Mvc\Property\PropertyMappingConfiguration::class;
 
         \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter(
             \TYPO3\CMS\Form\Mvc\Property\TypeConverter\UploadedFileReferenceConverter::class