[TASK] Add a signal after importer init in ImportExportUtility 65/30065/7
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Sun, 4 May 2014 15:21:02 +0000 (17:21 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 21 Jun 2014 16:48:49 +0000 (18:48 +0200)
To be able to modify importer options on importing T3D-files on
extension installation (e.g. for distributions) this patch introduces
a signal in ImportExportUtility.

Resolves: #58782
Releases: 6.3, 6.2
Change-Id: I9a3dec39efe4b8205013614cef1624720aab402a
Reviewed-on: https://review.typo3.org/30065
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/impexp/Classes/Utility/ImportExportUtility.php

index f464046..4722314 100644 (file)
@@ -28,6 +28,8 @@ namespace TYPO3\CMS\Impexp\Utility;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Utility for import / export
  * Can be used for API access for simple importing of files
@@ -53,9 +55,11 @@ class ImportExportUtility {
                        throw new \InvalidArgumentException('Input parameter $int has to be of type integer', 1377625646);
                }
                /** @var $import \TYPO3\CMS\Impexp\ImportExport */
-               $import = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport');
+               $import = GeneralUtility::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport');
                $import->init(0, 'import');
 
+               $this->emitAfterImportExportInitialisationSignal($import);
+
                if ($file && @is_file($file)) {
                        if ($import->loadFile($file, 1)) {
                                // Import to root page:
@@ -74,4 +78,24 @@ class ImportExportUtility {
                        return $importResponse;
                }
        }
+
+       /**
+        * Get the SignalSlot dispatcher
+        *
+        * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        */
+       protected function getSignalSlotDispatcher() {
+               return GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
+       }
+
+       /**
+        * Emits a signal after initialization
+        *
+        * @param \TYPO3\CMS\Impexp\ImportExport $import
+        * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
+        * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException
+        */
+       protected function emitAfterImportExportInitialisationSignal(\TYPO3\CMS\Impexp\ImportExport $import) {
+               $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'afterImportExportInitialisation', array($import));
+       }
 }