From ae887f6a67eaa34bcf6cd9566c9e45a07bb67f7e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 7 Oct 2013 13:03:28 +0200 Subject: [PATCH] validate country removal --- core/lib/Thelia/Action/Country.php | 5 +++++ core/lib/Thelia/Config/Resources/routing/admin.xml | 4 ++++ templates/admin/default/countries.html | 13 ++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Action/Country.php b/core/lib/Thelia/Action/Country.php index 1fa90b6b9..f4f59b2bb 100644 --- a/core/lib/Thelia/Action/Country.php +++ b/core/lib/Thelia/Action/Country.php @@ -29,6 +29,7 @@ use Thelia\Core\Event\Country\CountryDeleteEvent; use Thelia\Core\Event\Country\CountryUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Country as CountryModel; +use Thelia\Model\CountryQuery; /** @@ -62,7 +63,11 @@ class Country extends BaseAction implements EventSubscriberInterface public function delete(CountryDeleteEvent $event) { + if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) { + $country->delete(); + $event->setCountry($country); + } } diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 47208fdb4..c69c0659d 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -420,6 +420,10 @@ \d+ + + Thelia\Controller\Admin\CountryController::deleteAction + + Thelia\Controller\Admin\ContentController::createAction diff --git a/templates/admin/default/countries.html b/templates/admin/default/countries.html index 21d3819e4..3207357a1 100644 --- a/templates/admin/default/countries.html +++ b/templates/admin/default/countries.html @@ -216,10 +216,17 @@ {/javascripts}