From da7fcc4274ca15bf9116559a81eee77972c45697 Mon Sep 17 00:00:00 2001 From: franck Date: Tue, 3 Sep 2013 18:58:51 +0200 Subject: [PATCH] Added route methods --- core/lib/Thelia/Controller/BaseController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index c7c9f6f14..49d65f22f 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -36,6 +36,7 @@ use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; use Symfony\Component\EventDispatcher\Event; use Thelia\Core\Event\DefaultActionEvent; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * @@ -200,4 +201,20 @@ class BaseController extends ContainerAware if (null !== $url) $this->redirect($url); } + + /** + * Get a route path from the route id. + * + * @param unknown $routerName either admin.router or front.router + * @param unknown $routeName the route ID + */ + protected function getRouteFromRouter($routerName, $routeId) { + $route = $this->container->get($routerName)->getRouteCollection()->get($routeId); + + if ($route == null) { + throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId)); + } + + return $route->getPath(); + } }