create event object for module delete action
This commit is contained in:
@@ -22,10 +22,13 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Cache\CacheEvent;
|
||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Map\ModuleTableMap;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
@@ -59,6 +62,11 @@ class Module extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(ModuleDeleteEvent $event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function cacheClear()
|
||||
{
|
||||
$cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir'));
|
||||
@@ -89,7 +97,8 @@ class Module extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128)
|
||||
TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128),
|
||||
TheliaEvents::MODULE_DELETE => array('delete', 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,6 +825,10 @@
|
||||
<requirement key="module_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.delete" path="/admin/configuration/modules/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end Modules rule management -->
|
||||
|
||||
<!-- tax management -->
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Module\ModuleManagement;
|
||||
@@ -82,4 +83,21 @@ class ModuleController extends BaseAdminController
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.module.delete")) return $response;
|
||||
|
||||
try {
|
||||
|
||||
$module_id = $this->getRequest()->get('module_id');
|
||||
|
||||
$deleteEvent = new ModuleDeleteEvent($module_id);
|
||||
|
||||
$this->dispatch(TheliaEvents::MODULE_DELETE, $deleteEvent);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
61
core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php
Normal file
61
core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\Module;
|
||||
|
||||
|
||||
/**
|
||||
* Class ModuleDeleteEvent
|
||||
* @package Thelia\Core\Event\Module
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ModuleDeleteEvent extends ModuleEvent
|
||||
{
|
||||
/**
|
||||
* @var int module id
|
||||
*/
|
||||
protected $module_id;
|
||||
|
||||
function __construct($module_id)
|
||||
{
|
||||
$this->module_id = $module_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $module_id
|
||||
*/
|
||||
public function setModuleId($module_id)
|
||||
{
|
||||
$this->module_id = $module_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getModuleId()
|
||||
{
|
||||
return $this->module_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -665,6 +665,11 @@ final class TheliaEvents
|
||||
*/
|
||||
const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation';
|
||||
|
||||
/**
|
||||
* sent when a module is deleted
|
||||
*/
|
||||
const MODULE_DELETE = 'thelia.module.delete';
|
||||
|
||||
/**
|
||||
* sent for clearing cache
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this module'}" href="#delete_module_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
<a class="btn btn-default btn-xs module-delete-action" title="{intl l='Delete this module'}" href="#delete_module_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
{* Delete module confirmation dialog *}
|
||||
|
||||
{capture "delete_module_dialog"}
|
||||
<input type="hidden" name="current_module_id" value="{$current_module_id}" />
|
||||
<input type="hidden" name="module_id" id="delete_module_id" value"" />
|
||||
<input type="hidden" name="module_id" id="delete_module_id" value="" />
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
@@ -51,7 +50,7 @@
|
||||
dialog_title = {intl l="Delete a module"}
|
||||
dialog_message = {intl l="Do you really want to delete this module ?"}
|
||||
|
||||
form_action = {url path='/admin/modules/delete'}
|
||||
form_action = {url path='/admin/configuration/modules/delete'}
|
||||
form_content = {$smarty.capture.delete_module_dialog nofilter}
|
||||
}
|
||||
|
||||
@@ -95,6 +94,10 @@
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(".module-delete-action").click(function(){
|
||||
$("#delete_module_id").val($(this).data("id"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user