Added route methods

This commit is contained in:
franck
2013-09-03 18:58:51 +02:00
parent fce528c41f
commit da7fcc4274

View File

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