diff --git a/typo3/sysext/core/Classes/Resource/Event/AfterFileCopiedEvent.php b/typo3/sysext/core/Classes/Resource/Event/AfterFileCopiedEvent.php index f13fc17037a9b1b84e5821f8515a39f2e28169ce..0e30eeae8158ccba91f6f455644c2d52ec222923 100644 --- a/typo3/sysext/core/Classes/Resource/Event/AfterFileCopiedEvent.php +++ b/typo3/sysext/core/Classes/Resource/Event/AfterFileCopiedEvent.php @@ -38,10 +38,22 @@ final class AfterFileCopiedEvent */ private $folder; - public function __construct(FileInterface $file, Folder $folder) + /** + * @var string + */ + private $newFileIdentifier; + + /** + * @var FileInterface|null + */ + private $newFile; + + public function __construct(FileInterface $file, Folder $folder, string $newFileIdentifier, ?FileInterface $newFile) { $this->file = $file; $this->folder = $folder; + $this->newFileIdentifier = $newFileIdentifier; + $this->newFile = $newFile; } public function getFile(): FileInterface @@ -53,4 +65,14 @@ final class AfterFileCopiedEvent { return $this->folder; } + + public function getNewFileIdentifier(): string + { + return $this->newFileIdentifier; + } + + public function getNewFile(): ?FileInterface + { + return $this->newFile; + } } diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php index b5f316471291912848c769bacb70db10713f7a17..dcb46901b82ac8115317a2352c9b6978017c8573 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php +++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php @@ -1949,7 +1949,7 @@ class ResourceStorage implements ResourceStorageInterface $newFileObject = $this->getResourceFactoryInstance()->getFileObjectByStorageAndIdentifier($this->getUid(), $newFileObjectIdentifier); $this->eventDispatcher->dispatch( - new AfterFileCopiedEvent($file, $targetFolder) + new AfterFileCopiedEvent($file, $targetFolder, $newFileObjectIdentifier, $newFileObject) ); return $newFileObject; } diff --git a/typo3/sysext/core/Documentation/Changelog/10.2/Feature-89577-NewPSR-14BasedEventsForFileAbstractionLayer.rst b/typo3/sysext/core/Documentation/Changelog/10.2/Feature-89577-NewPSR-14BasedEventsForFileAbstractionLayer.rst index 25111761dc3731e04c003ef7efc688edea5fd486..fcce14114ddf08e83aea86816a625c5f5d75577b 100644 --- a/typo3/sysext/core/Documentation/Changelog/10.2/Feature-89577-NewPSR-14BasedEventsForFileAbstractionLayer.rst +++ b/typo3/sysext/core/Documentation/Changelog/10.2/Feature-89577-NewPSR-14BasedEventsForFileAbstractionLayer.rst @@ -63,6 +63,9 @@ it is highly encouraged to migrate to the new PSR-14 based events. In addition, all Core hooks using these events have been migrated to new PSR-14 events, all new Events have a description when to use them and what the benefits are. +The Event `AfterFileCopiedEvent` in addition also contains the newly created File +object. + Have a look at the new PHP classes to understand the Events and to learn more about PSR-14. .. index:: FAL, PHP-API, ext:core