From a987808bdf6d153ec2fe75d983979c614784c17d Mon Sep 17 00:00:00 2001 From: touffies Date: Wed, 11 Dec 2013 20:58:00 +0100 Subject: [PATCH] Add new method redirectToListTemplateWithId --- .../Controller/Admin/CategoryController.php | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index bb37c046f..4f789244b 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -195,10 +195,25 @@ class CategoryController extends AbstractSeoCrudController protected function redirectToListTemplate() { - $this->redirectToRoute( + $category_id = $this->getRequest()->get('category_id', 0); + $this->redirectToListTemplateWithId($category_id); + } + + protected function redirectToListTemplateWithId($category_id) + { + if($category_id > 0) + { + $this->redirectToRoute( 'admin.categories.default', - array('category_id' => $this->getRequest()->get('category_id', 0)) - ); + array('category_id' => $category_id) + ); + } + else + { + $this->redirectToRoute( + 'admin.catalog' + ); + } } protected function renderEditionTemplate() @@ -235,21 +250,16 @@ class CategoryController extends AbstractSeoCrudController protected function performAdditionalDeleteAction($deleteEvent) { // Redirect to parent category list - $this->redirectToRoute( - 'admin.categories.default', - array('category_id' => $deleteEvent->getCategory()->getParent()) - ); + $category_id = $deleteEvent->getCategory()->getParent(); + $this->redirectToListTemplateWithId($category_id); } protected function performAdditionalUpdateAction($updateEvent) { if ($this->getRequest()->get('save_mode') != 'stay') { - // Redirect to parent category list - $this->redirectToRoute( - 'admin.categories.default', - array('category_id' => $updateEvent->getCategory()->getParent()) - ); + $category_id = $updateEvent->getCategory()->getParent(); + $this->redirectToListTemplateWithId($category_id); } } @@ -260,10 +270,8 @@ class CategoryController extends AbstractSeoCrudController if ($category != null) { // Redirect to parent category list - $this->redirectToRoute( - 'admin.categories.default', - array('category_id' => $category->getParent()) - ); + $category_id = $category->getParent(); + $this->redirectToListTemplateWithId($category_id); } return null;