diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller.php index 1913d58f49..03c90eca23 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller.php @@ -5,7 +5,6 @@ namespace Symfony\Bundle\FrameworkBundle; use Symfony\Components\DependencyInjection\ContainerInterface; use Symfony\Components\HttpFoundation\Request; use Symfony\Components\HttpFoundation\Response; -use Symfony\Components\HttpKernel\HttpKernelInterface; /* * This file is part of the Symfony framework. @@ -93,10 +92,7 @@ class Controller */ public function forward($controller, array $path = array(), array $query = array()) { - $path['_controller'] = $controller; - $subRequest = $this->getRequest()->duplicate($query, null, $path); - - return $this->container->get('kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); + return $this->container->get('controller_resolver')->forward($controller, $path, $query); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php index 0c5be141d5..8ef02ffe77 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php @@ -69,6 +69,23 @@ class ControllerResolver extends BaseControllerResolver return array(new $class($this->container), $method); } + /** + * Forwards the request to another controller. + * + * @param string $controller The controller name (a string like BlogBundle:Post:index) + * @param array $path An array of path parameters + * @param array $query An array of query parameters + * + * @return Response A Response instance + */ + public function forward($controller, array $path = array(), array $query = array()) + { + $path['_controller'] = $controller; + $subRequest = $this->getRequest()->duplicate($query, null, $path); + + return $this->container->get('kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); + } + /** * Renders a Controller and returns the Response content. *