remove country from area and start creating postage management
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\AreaQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
@@ -48,6 +49,14 @@ class Area extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function removeCountry(AreaRemoveCountryEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country->setAreaId(null)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
@@ -72,7 +81,8 @@ class Area extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128)
|
||||
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128),
|
||||
TheliaEvents::AREA_REMOVE_COUNTRY => array('removeCountry', 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +128,7 @@
|
||||
<form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/>
|
||||
<form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/>
|
||||
<form name="thelia.admin.area.country" class="Thelia\Form\Area\AreaCountryForm"/>
|
||||
<form name="thelia.admin.area.postage" class="Thelia\Form\Area\AreaPostageForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -696,10 +696,19 @@
|
||||
<requirement key="area_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.update.postage" path="/admin/configuration/shipping_configuration/update_postage/{area_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::updatePostageAction</default>
|
||||
<requirement key="area_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.country.add" path="/admin/configuration/shipping_configuration/country/add" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::addCountry</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.country.remove" path="/admin/configuration/shipping_configuration/country/remove" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::removeCountry</default>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaCreateEvent;
|
||||
use Thelia\Core\Event\Area\AreaDeleteEvent;
|
||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Area\AreaCountryForm;
|
||||
@@ -271,4 +272,16 @@ class AreaController extends AbstractCrudController
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
public function removeCountry()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
$request = $this->getRequest();
|
||||
$removeCountryEvent = new AreaRemoveCountryEvent($request->request->get('areai_id', 0), $request->request->get('country_id', 0));
|
||||
|
||||
$this->dispatch(TheliaEvents::AREA_REMOVE_COUNTRY, $removeCountryEvent);
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,9 @@ final class TheliaEvents
|
||||
const AREA_CREATE = 'action.createArea';
|
||||
const AREA_UPDATE = 'action.updateArea';
|
||||
const AREA_DELETE = 'action.deleteArea';
|
||||
|
||||
const AREA_ADD_COUNTRY = 'action.area.addCountry';
|
||||
const AREA_REMOVE_COUNTRY = 'action.area.removeCountry';
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user