diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 815ea162a..b20ed0d19 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -25,6 +25,8 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Exception\UrlRewritingException; +use Thelia\Form\Exception\FormValidationException; use Thelia\Model\CategoryQuery; use Thelia\Model\Category as CategoryModel; @@ -90,6 +92,13 @@ class Category extends BaseAction implements EventSubscriberInterface ->save(); + // Update the rewritten URL, if required + try { + $category->setRewrittenUrl($event->getLocale(), $event->getUrl()); + } catch(UrlRewritingException $e) { + throw new FormValidationException($e->getMessage()); + } + $event->setCategory($category); } } diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php index 3c027ad04..61291556a 100644 --- a/core/lib/Thelia/Action/Content.php +++ b/core/lib/Thelia/Action/Content.php @@ -32,6 +32,8 @@ use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; use Thelia\Core\Event\Content\ContentUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Exception\UrlRewritingException; +use Thelia\Form\Exception\FormValidationException; use Thelia\Model\ContentFolder; use Thelia\Model\ContentFolderQuery; use Thelia\Model\ContentQuery; @@ -79,6 +81,13 @@ class Content extends BaseAction implements EventSubscriberInterface ->save() ; + // Update the rewritten URL, if required + try { + $content->setRewrittenUrl($event->getLocale(), $event->getUrl()); + } catch(UrlRewritingException $e) { + throw new FormValidationException($e->getMessage()); + } + $content->updateDefaultFolder($event->getDefaultFolder()); $event->setContent($content); diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php index a42330e47..a6ae543bf 100644 --- a/core/lib/Thelia/Action/Folder.php +++ b/core/lib/Thelia/Action/Folder.php @@ -29,6 +29,8 @@ use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent; use Thelia\Core\Event\Folder\FolderUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Exception\UrlRewritingException; +use Thelia\Form\Exception\FormValidationException; use Thelia\Model\FolderQuery; use Thelia\Model\Folder as FolderModel; @@ -56,6 +58,13 @@ class Folder extends BaseAction implements EventSubscriberInterface ->save(); ; + // Update the rewritten URL, if required + try { + $folder->setRewrittenUrl($event->getLocale(), $event->getUrl()); + } catch(UrlRewritingException $e) { + throw new FormValidationException($e->getMessage()); + } + $event->setFolder($folder); } } diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 4fccbf3f6..90176b8ba 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -25,6 +25,8 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Exception\UrlRewritingException; +use Thelia\Form\Exception\FormValidationException; use Thelia\Model\ProductQuery; use Thelia\Model\Product as ProductModel; @@ -114,7 +116,11 @@ class Product extends BaseAction implements EventSubscriberInterface ; // Update the rewritten URL, if required - $product->setRewrittenUrl($event->getLocale(), $event->getUrl()); + try { + $product->setRewrittenUrl($event->getLocale(), $event->getUrl()); + } catch(UrlRewritingException $e) { + throw new FormValidationException($e->getMessage()); + } // Update default category (ifd required) $product->updateDefaultCategory($event->getDefaultCategory());