allow to delete content

This commit is contained in:
Manuel Raynaud
2013-09-23 12:40:01 +02:00
parent 7bc34d3d0f
commit fea156635d
5 changed files with 116 additions and 3 deletions

View File

@@ -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.