Get main request in Symfony 2.4

When rendering another controller from the view, the main request is lost - this means that, for example, GET parameters will not be available in that processed (enabled) controller.

What is the way to access the query string in the handled controllers except directly accessing $ _GET (this works).

I found some legacy code in the project that does this, but it's deprecated in version 2.4 and will already be removed in version 3.0:

$this->container->get('request_stack')->getMasterRequest();

      

Here $ this-> container is ContainerInterface.

+3


source to share


1 answer


http://api.symfony.com/master/Symfony/Component/HttpFoundation/RequestStack.html

From RequestStack

you can get the main query $stack->getMasterRequest()

.



Request as a service has been deprecated $this->container->get('request')

, but this stack has replaced it.

+7


source







All Articles