[TASK] Missing signals on adding folder 63/26863/2
authorFrans Saris <franssaris@gmail.com>
Wed, 15 Jan 2014 21:28:58 +0000 (22:28 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Thu, 30 Jan 2014 11:28:56 +0000 (12:28 +0100)
There are signals for most filestorage operations performed
in the ResourceStorage, but not for adding a folder.

This patch adds the two missing signals.

Resolves: #54964
Releases: 6.2
Change-Id: Ia7e3970ea278bf5e74856008afe53083e91f0649
Reviewed-on: https://review.typo3.org/26863
Reviewed-by: Stefan Neufeind
Reviewed-by: Andreas Wolf
Tested-by: Andreas Wolf
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index ccf961b..55aa737 100644 (file)
@@ -82,6 +82,8 @@ class ResourceStorage {
        const SIGNAL_PostFileRename = 'postFileRename';
        const SIGNAL_PreFileReplace = 'preFileReplace';
        const SIGNAL_PostFileReplace = 'postFileReplace';
+       const SIGNAL_PreFolderAdd = 'preFolderAdd';
+       const SIGNAL_PostFolderAdd = 'postFolderAdd';
        const SIGNAL_PreFolderCopy = 'preFolderCopy';
        const SIGNAL_PostFolderCopy = 'postFolderCopy';
        const SIGNAL_PreFolderMove = 'preFolderMove';
@@ -1968,8 +1970,15 @@ class ResourceStorage {
                if (!$this->checkFolderActionPermission('add', $parentFolder)) {
                        throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
                }
+
+               $this->emitPreFolderAddSignal($parentFolder, $folderName);
+
                $newFolder = $this->getDriver()->createFolder($folderName, $parentFolder->getIdentifier(), TRUE);
-               return $this->getFolder($newFolder);
+               $newFolder = $this->getFolder($newFolder);
+
+               $this->emitPostFolderAddSignal($newFolder);
+
+               return $newFolder;
        }
 
        /**
@@ -2158,6 +2167,27 @@ class ResourceStorage {
        }
 
        /**
+        * Emits the folder pre-add signal
+        *
+        * @param Folder $targetFolder
+        * @param string $name
+        * @return void
+        */
+       protected function emitPreFolderAddSignal(Folder $targetFolder, $name) {
+               $this->getSignalSlotDispatcher()->dispatch('ResourceStorage', self::SIGNAL_PreFolderAdd, array($targetFolder, $name));
+       }
+
+       /**
+        * Emits the folder post-add signal
+        *
+        * @param Folder $folder
+        * @return void
+        */
+       protected function emitPostFolderAddSignal(Folder $folder) {
+               $this->getSignalSlotDispatcher()->dispatch('ResourceStorage', self::SIGNAL_PostFolderAdd, array($folder));
+       }
+
+       /**
         * Emits the folder pre-copy signal
         *
         * @param Folder $folder