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)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user