From eb5056f08909774ed39bc30e4d2103e8cb24a20e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 14 Jan 2014 14:39:08 +0100 Subject: [PATCH] AbstractController::getExistingObject return object with hte needed locale inside --- .../Thelia/Controller/Admin/CategoryController.php | 11 ++++++++--- .../lib/Thelia/Controller/Admin/ContentController.php | 8 ++++++-- core/lib/Thelia/Controller/Admin/FolderController.php | 8 ++++++-- .../lib/Thelia/Controller/Admin/ProductController.php | 11 ++++++++--- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index d2e0a0e9c..8dcba2cbe 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -156,9 +156,14 @@ class CategoryController extends AbstractSeoCrudController protected function getExistingObject() { - return CategoryQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) - ->findOneById($this->getRequest()->get('category_id', 0)); + $category = CategoryQuery::create() + ->findOneById($this->getRequest()->get('category_id', 0)); + + if (null !== $category) { + $category->setLocale($this->getCurrentEditionLocale()); + } + + return $category; } protected function getObjectLabel($object) diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php index bcb588800..472d249ee 100644 --- a/core/lib/Thelia/Controller/Admin/ContentController.php +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -236,9 +236,13 @@ class ContentController extends AbstractSeoCrudController */ protected function getExistingObject() { - return ContentQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) + $content = ContentQuery::create() ->findOneById($this->getRequest()->get('content_id', 0)); + + if (null !== $content) { + $content->setLocale($this->getCurrentEditionLocale()); + } + return $content; } /** diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php index d34ebf283..5d1f13293 100644 --- a/core/lib/Thelia/Controller/Admin/FolderController.php +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -199,9 +199,13 @@ class FolderController extends AbstractSeoCrudController */ protected function getExistingObject() { - return FolderQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) + $folder = FolderQuery::create() ->findOneById($this->getRequest()->get('folder_id', 0)); + + if (null !== $folder) { + $folder->setLocale($this->getCurrentEditionLocale()); + } + return $folder; } /** diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 549ee6609..38cd917ea 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -343,9 +343,14 @@ class ProductController extends AbstractSeoCrudController protected function getExistingObject() { - return ProductQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) - ->findOneById($this->getRequest()->get('product_id', 0)); + $product = ProductQuery::create() + ->findOneById($this->getRequest()->get('product_id', 0)); + + if (null !== $product) { + $product->setLocale($this->getCurrentEditionLocale()); + } + + return $product; } protected function getObjectLabel($object)