url management in backoffice

This commit is contained in:
Etienne Roudeix
2013-12-09 11:28:13 +01:00
parent cc4fce9add
commit f4a2744d19
4 changed files with 34 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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());