I understand that using {% render() %}
automatically forces a new request object to be sent, but im curious if theres a way to pass in the originating request a
If I understand correctly, you're looking for this:
{% render "MyBundle:Controller:someAction" with { 'originalRequest' : app.request } %}
use the render function as a result
{{ render(controller('MyBundle:ControllerName:example', {'originalRequest': app.request})) }}
and then in your controller
public function exampleAction(Request $originalRequest)
{
// do something
}
Since Symfony 2.4 you can access the original request via the request_stack. This avoids the need to create a new method parameter.
function exampleAction() {
$request = $this->get('request_stack')->getMasterRequest();
//do something
}
Use this carefully as it makes your sub-requests incompatible with ESIs/reverse proxies (where a sub-request is also a master request) http://symfony.com/blog/new-in-symfony-2-4-the-request-stack