enabled change default country

This commit is contained in:
Manuel Raynaud
2013-10-08 10:16:18 +02:00
parent d45074051e
commit 43467681fd
9 changed files with 107 additions and 8 deletions

View File

@@ -24,6 +24,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Country\CountryCreateEvent;
use Thelia\Core\Event\Country\CountryDeleteEvent;
use Thelia\Core\Event\Country\CountryToggleDefaultEvent;
use Thelia\Core\Event\Country\CountryUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CountryCreationForm;
@@ -245,4 +246,25 @@ class CountryController extends AbstractCrudController
{
$this->redirectToRoute('admin.configuration.countries.default');
}
public function toggleDefaultAction()
{
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$content = null;
if (null !== $country_id = $this->getRequest()->get('country_id')) {
$toogleDefaultEvent = new CountryToggleDefaultEvent($country_id);
try {
$this->dispatch(TheliaEvents::COUNTRY_TOGGLE_DEFAULT, $toogleDefaultEvent);
if($toogleDefaultEvent->hasCountry()) {
return $this->nullResponse();
}
} catch (\Exception $ex) {
$content = $ex->getMessage();
}
}
return $this->nullResponse($content, 500);
}
}