diff --git a/core/data/event/BeforeResourceDeleted.php b/core/data/event/BeforeResourceDeleted.php new file mode 100755 index 000000000..035d59302 --- /dev/null +++ b/core/data/event/BeforeResourceDeleted.php @@ -0,0 +1,48 @@ +uri = $uri; + } + + public function getUri(): string + { + return $this->uri; + } + + /** + * {@inheritdoc} + */ + public function getName(): string + { + return __CLASS__; + } +} diff --git a/core/resource/Repository/ResourceRepository.php b/core/resource/Repository/ResourceRepository.php index 974ee1876..9a7f4a864 100644 --- a/core/resource/Repository/ResourceRepository.php +++ b/core/resource/Repository/ResourceRepository.php @@ -22,6 +22,7 @@ namespace oat\generis\model\resource\Repository; +use oat\generis\model\data\event\BeforeResourceDeleted; use RuntimeException; use BadMethodCallException; use InvalidArgumentException; @@ -68,6 +69,9 @@ public function delete(ContextInterface $context): void false ); + $beforeResourceDeletedEvent = new BeforeResourceDeleted($resource->getUri()); + $this->eventManager->trigger($beforeResourceDeletedEvent); + if (!$this->getImplementation()->delete($resource, $deleteReference)) { throw new RuntimeException( sprintf(