icreate folder delete event

This commit is contained in:
Manuel Raynaud
2013-09-20 19:49:12 +02:00
parent 6a1df0240e
commit 56197a739e
4 changed files with 85 additions and 3 deletions

View File

@@ -208,6 +208,10 @@
<default key="_controller">Thelia\Controller\Admin\FolderController::processUpdateAction</default>
</route>
<route id="admin.categories.delete" path="/admin/folders/delete">
<default key="_controller">Thelia\Controller\Admin\FolderController::deleteAction</default>
</route>
<!-- Route to the Coupon controller (process Coupon browsing) -->
<route id="admin.coupon.list" path="/admin/coupon/">

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\FolderDeleteEvent;
use Thelia\Core\Event\FolderUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\FolderModificationForm;
@@ -133,7 +134,7 @@ class FolderController extends AbstractCrudController
*/
protected function getDeleteEvent()
{
// TODO: Implement getDeleteEvent() method.
return new FolderDeleteEvent($this->getRequest()->get('folder_id'), 0);
}
/**
@@ -149,11 +150,13 @@ class FolderController extends AbstractCrudController
/**
* Get the created object from an event.
*
* @param unknown $createEvent
* @param $event \Thelia\Core\Event\FolderEvent $event
*
* @return null|\Thelia\Model\Folder
*/
protected function getObjectFromEvent($event)
{
// TODO: Implement getObjectFromEvent() method.
return $event->hasFolder() ? $event->getFolder() : null;
}
/**
@@ -235,6 +238,12 @@ class FolderController extends AbstractCrudController
}
}
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\FolderDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
// Redirect to parent category list

View File

@@ -0,0 +1,64 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
/**
* Class FolderDeleteEvent
* @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class FolderDeleteEvent extends FolderEvent{
/**
* @var int folder id
*/
protected $folder_id;
/**
* @param int $folder_id
*/
function __construct($folder_id)
{
$this->folder_id = $folder_id;
}
/**
* @param int $folder_id
*/
public function setFolderId($folder_id)
{
$this->folder_id = $folder_id;
}
/**
* @return int
*/
public function getFolderId()
{
return $this->folder_id;
}
}

View File

@@ -60,6 +60,11 @@ class FolderEvent extends ActionEvent {
return $this->folder;
}
/**
* test if a folder object exists
*
* @return bool
*/
public function hasFolder()
{
return null !== $this->folder;