remove country from area and start creating postage management

This commit is contained in:
Manuel Raynaud
2013-10-14 11:03:13 +02:00
parent dfee7e87a6
commit b371f5c54c
6 changed files with 64 additions and 7 deletions

View File

@@ -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)
);
}
}