diff --git a/src/Symfony/Framework/WebBundle/Controller.php b/src/Symfony/Framework/WebBundle/Controller.php index 75fe3384f7..d23ad2a097 100644 --- a/src/Symfony/Framework/WebBundle/Controller.php +++ b/src/Symfony/Framework/WebBundle/Controller.php @@ -3,6 +3,7 @@ namespace Symfony\Framework\WebBundle; use Symfony\Components\DependencyInjection\ContainerInterface; +use Symfony\Components\RequestHandler\Request; use Symfony\Components\RequestHandler\Response; /* @@ -24,6 +25,7 @@ use Symfony\Components\RequestHandler\Response; class Controller { protected $container; + protected $request; function __construct(ContainerInterface $container) { @@ -32,7 +34,17 @@ class Controller public function getRequest() { - return $this->container->getRequestService(); + if (null === $this->request) + { + $this->request = $this->container->getRequestService(); + } + + return $this->request; + } + + public function setRequest(Request $request) + { + return $this->request = $request; } public function getUser() diff --git a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php index ae0a94403f..76127507b4 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php +++ b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php @@ -69,6 +69,7 @@ class ControllerLoader } $controller = $this->findController($bundle, $controller, $action); + $controller[0]->setRequest($request); $r = new \ReflectionObject($controller[0]); $arguments = $this->getMethodArguments($r->getMethod($controller[1]), $event->getParameter('request')->path->all(), sprintf('%s::%s()', get_class($controller[0]), $controller[1]));