allow to delete content
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Content\ContentCreateEvent;
|
||||
use Thelia\Core\Event\Content\ContentDeleteEvent;
|
||||
use Thelia\Core\Event\Content\ContentToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -110,6 +111,19 @@ class Content extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
}
|
||||
|
||||
public function delete(ContentDeleteEvent $event)
|
||||
{
|
||||
if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) {
|
||||
$defaultFolderId = $content->getDefaultFolderId();
|
||||
|
||||
$content->setDispatcher($this->getDispatcher())
|
||||
->delete();
|
||||
|
||||
$event->setDefaultFolderId($defaultFolderId);
|
||||
$event->setContent($content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
|
||||
Reference in New Issue
Block a user