create contentAddFolder process
This commit is contained in:
@@ -22,13 +22,17 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Content\ContentAddFolderEvent;
|
||||
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;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\ContentFolder;
|
||||
use Thelia\Model\ContentFolderQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\Content as ContentModel;
|
||||
|
||||
@@ -123,6 +127,23 @@ class Content extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addFolder(ContentAddFolderEvent $event)
|
||||
{
|
||||
if(ContentFolderQuery::create()
|
||||
->filterByContent($event->getContent())
|
||||
->filterByFolderId($event->getFolderId())
|
||||
->count() <= 0
|
||||
) {
|
||||
$contentFolder = new ContentFolder();
|
||||
|
||||
$contentFolder
|
||||
->setFolderId($event->getFolderId())
|
||||
->setContent($event->getContent())
|
||||
->setDefaultFolder(false)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
@@ -146,12 +167,15 @@ class Content extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CONTENT_CREATE => array("create", 128),
|
||||
TheliaEvents::CONTENT_UPDATE => array("update", 128),
|
||||
TheliaEvents::CONTENT_DELETE => array("delete", 128),
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
TheliaEvents::CONTENT_CREATE => array('create', 128),
|
||||
TheliaEvents::CONTENT_UPDATE => array('update', 128),
|
||||
TheliaEvents::CONTENT_DELETE => array('delete', 128),
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array('toggleVisibility', 128),
|
||||
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION => array('updatePosition', 128),
|
||||
|
||||
TheliaEvents::CONTENT_ADD_FOLDER => array('addFolder', 128),
|
||||
TheliaEvents::CONTENT_REMOVE_FOLDER => array('removeFolder', 128),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user