[FEATURE] Introduce beforeCallActionMethod signal
authorAlexander Schnitzler <alex.schnitzler@typovision.de>
Fri, 4 Jan 2013 12:28:28 +0000 (13:28 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 5 Jan 2013 20:46:22 +0000 (21:46 +0100)
This patch introduces a signal for hooking in
right before calling the action method of the
controller. The slots are given the controller
name, the action name and the action arguments.

Relases: 6.1
Resolves: #7397
Change-Id: I09fbf75356060b4a0129c12ff2087e686016e442
Reviewed-on: https://review.typo3.org/17380
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ActionControllerTest.php

index 268a700..a011abe 100644 (file)
@@ -36,7 +36,10 @@ abstract class AbstractController implements \TYPO3\CMS\Extbase\Mvc\Controller\C
 
        /**
         * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+<<<<<<< HEAD
         * @inject
+=======
+>>>>>>> 39173cc... [FEATURE] Introduce beforeCallActionMethod signal
         */
        protected $signalSlotDispatcher;
 
@@ -202,6 +205,16 @@ abstract class AbstractController implements \TYPO3\CMS\Extbase\Mvc\Controller\C
        }
 
        /**
+        * injects the signal slot dispatcher
+        *
+        * @param \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher
+        * @return void
+        */
+       public function injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher) {
+               $this->signalSlotDispatcher = $signalSlotDispatcher;
+       }
+
+       /**
         * Checks if the current request type is supported by the controller.
         *
         * If your controller only supports certain request types, either
index e47ca6f..51ee805 100644 (file)
@@ -100,6 +100,8 @@ class ActionControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockArgumentMappingResults = $this->getMock('TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction', 'initializeAction'), array(), '', FALSE);
+               $mockSignalSlotDispatcher = $this->getMock('TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(), '', FALSE);
+               $mockController->injectSignalSlotDispatcher($mockSignalSlotDispatcher);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $mockController->expects($this->once())->method('fooAction')->will($this->returnValue('the returned string'));
                $mockController->_set('request', $mockRequest);
@@ -124,6 +126,8 @@ class ActionControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockArgumentMappingResults = $this->getMock('TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction', 'initializeAction'), array(), '', FALSE);
+               $mockSignalSlotDispatcher = $this->getMock('TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(), '', FALSE);
+               $mockController->injectSignalSlotDispatcher($mockSignalSlotDispatcher);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $mockController->expects($this->once())->method('fooAction');
                $mockController->_set('request', $mockRequest);
@@ -172,6 +176,8 @@ class ActionControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockArgumentMappingResults = $this->getMock('TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction', 'initializeAction'), array(), '', FALSE);
+               $mockSignalSlotDispatcher = $this->getMock('TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(), '', FALSE);
+               $mockController->injectSignalSlotDispatcher($mockSignalSlotDispatcher);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $mockController->expects($this->once())->method('fooAction')->with('Default value');
                $mockController->_set('request', $mockRequest);