diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php index 12d78e125..97e023993 100644 --- a/core/lib/Thelia/Action/Folder.php +++ b/core/lib/Thelia/Action/Folder.php @@ -23,6 +23,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\FolderDeleteEvent; use Thelia\Core\Event\FolderUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\FolderQuery; @@ -57,6 +58,16 @@ class Folder extends BaseAction implements EventSubscriberInterface { } } + public function delete(FolderDeleteEvent $event) + { + if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { + $folder->setDispatcher($this->getDispatcher()) + ->delete(); + + $event->setFolder($folder); + } + } + /** * Returns an array of event names this subscriber wants to listen to. * diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index 128c5932a..ffd1c38ef 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -2,6 +2,8 @@ namespace Thelia\Model; +use Thelia\Core\Event\FolderEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Folder as BaseFolder; use Thelia\Tools\URL; use Propel\Runtime\Connection\ConnectionInterface; @@ -67,6 +69,37 @@ class Folder extends BaseFolder { $this->setPosition($this->getNextPosition()); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFOLDER, new FolderEvent($this)); + return true; } + + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFOLDER, new FolderEvent($this)); + } + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFOLDER, new FolderEvent($this)); + + return true; + } + + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFOLDER, new FolderEvent($this)); + } + + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFOLDER, new FolderEvent($this)); + + return true; + } + + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this)); + } }