[TASK] Add signal in ResourceFactory for storage creation 33/23033/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 11 Aug 2013 16:28:42 +0000 (18:28 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 11 Aug 2013 18:17:36 +0000 (20:17 +0200)
We miss a central place to adapt or change
configuration for a resource storage.

Add a signal in the resource factory to be able
to post process a storage object after creation.

Releases: 6.0, 6.1, 6.2
Resolves: #51011
Change-Id: Iace95bc50ab149b4e62dd85c01417b3a3e6bf1cf
Reviewed-on: https://review.typo3.org/23033
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Classes/Resource/ResourceFactory.php

index bd36cc9..6a5b8a0 100644 (file)
@@ -40,6 +40,8 @@ use TYPO3\CMS\Core\Utility\PathUtility;
  */
 class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
 
+       const SIGNAL_PostProcessStorage = 'postProcessStorage';
+
        /**
         * Gets a singleton instance of this class.
         *
@@ -77,6 +79,18 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
        protected $localDriverStorageCache = NULL;
 
        /**
+        * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        */
+       protected $signalSlotDispatcher;
+
+       /**
+        * Inject signal slot dispatcher
+        */
+       public function __construct(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher = NULL) {
+               $this->signalSlotDispatcher = $signalSlotDispatcher ?: GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
+       }
+
+       /**
         * Creates a driver object for a specified storage object.
         *
         * @param string $driverIdentificationString The driver class (or identifier) to use.
@@ -142,6 +156,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        if (!$storageObject instanceof ResourceStorage) {
                                $storageObject = $this->createStorageObject($recordData, $storageConfiguration);
                        }
+                       $this->signalSlotDispatcher->dispatch('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', self::SIGNAL_PostProcessStorage, array($this, $storageObject));
                        $this->storageInstances[$uid] = $storageObject;
                }
                return $this->storageInstances[$uid];