diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php index 3f311caf3fc1..d3e7c7348b21 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php +++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php @@ -1680,6 +1680,7 @@ public function setFileContents(AbstractFile $file, $contents) { // Check if user is allowed to edit $this->assureFileWritePermissions($file); + $this->emitPreFileSetContentsSignal($file, $contents); // Call driver method to update the file and update file index entry afterwards $result = $this->driver->setFileContents($file->getIdentifier(), $contents); if ($file instanceof File) { @@ -1704,6 +1705,7 @@ public function setFileContents(AbstractFile $file, $contents) public function createFile($fileName, Folder $targetFolderObject) { $this->assureFileAddPermissions($targetFolderObject, $fileName); + $this->emitPreFileCreateSignal($fileName, $targetFolderObject); $newFileIdentifier = $this->driver->createFile($fileName, $targetFolderObject->getIdentifier()); $this->emitPostFileCreateSignal($newFileIdentifier, $targetFolderObject); return $this->getResourceFactoryInstance()->getFileObjectByStorageAndIdentifier($this->getUid(), $newFileIdentifier); @@ -2565,6 +2567,17 @@ protected function emitPostFileReplaceSignal(FileInterface $file, $localFilePath $this->getSignalSlotDispatcher()->dispatch(self::class, self::SIGNAL_PostFileReplace, [$file, $localFilePath]); } + /** + * Emits the file pre-create signal + * + * @param string $fileName + * @param Folder $targetFolder + */ + protected function emitPreFileCreateSignal(string $fileName, Folder $targetFolder) + { + $this->getSignalSlotDispatcher()->dispatch(self::class, self::SIGNAL_PreFileCreate, [$fileName, $targetFolder]); + } + /** * Emits the file post-create signal * @@ -2596,6 +2609,17 @@ protected function emitPostFileDeleteSignal(FileInterface $file) $this->getSignalSlotDispatcher()->dispatch(self::class, self::SIGNAL_PostFileDelete, [$file]); } + /** + * Emits the file pre-set-contents signal + * + * @param FileInterface $file + * @param mixed $content + */ + protected function emitPreFileSetContentsSignal(FileInterface $file, $content) + { + $this->getSignalSlotDispatcher()->dispatch(self::class, self::SIGNAL_PreFileSetContents, [$file, $content]); + } + /** * Emits the file post-set-contents signal * diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorageInterface.php b/typo3/sysext/core/Classes/Resource/ResourceStorageInterface.php index 83b60715d8fb..1ee4c98f3344 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceStorageInterface.php +++ b/typo3/sysext/core/Classes/Resource/ResourceStorageInterface.php @@ -22,6 +22,7 @@ interface ResourceStorageInterface const SIGNAL_SanitizeFileName = 'sanitizeFileName'; const SIGNAL_PreFileAdd = 'preFileAdd'; const SIGNAL_PostFileAdd = 'postFileAdd'; + const SIGNAL_PreFileCreate = 'preFileCreate'; const SIGNAL_PostFileCreate = 'postFileCreate'; const SIGNAL_PreFileCopy = 'preFileCopy'; const SIGNAL_PostFileCopy = 'postFileCopy'; @@ -33,6 +34,7 @@ interface ResourceStorageInterface const SIGNAL_PostFileRename = 'postFileRename'; const SIGNAL_PreFileReplace = 'preFileReplace'; const SIGNAL_PostFileReplace = 'postFileReplace'; + const SIGNAL_PreFileSetContents = 'preFileSetContents'; const SIGNAL_PostFileSetContents = 'postFileSetContents'; const SIGNAL_PreFolderAdd = 'preFolderAdd'; const SIGNAL_PostFolderAdd = 'postFolderAdd';