I'm trying to use the "forward" method from a main Controller. first I'm assuring me that the original "request" is sent from the first controller to the "forwarded controller" (If I do a var_dump in both controllers I get the same request object.). But when I try access to the "request object" from the twig rendered from forwarded controller, the app.request.get(_route), app.request.get(_route_params) and others are differents. It is as if the original request is lost only from twig globals.
namespace MyBundle\Controller;
//...
class BookingController extends Controller {
/**
* @Route("/book/hotel/{slug}", name="booking_hotel")
*/
public function establishmentAction(Request $request, $slug = null) {
\dump($request); // dumper 1
return $this->forward('ExpediaBundle:Booking:index', array('request' => $request);
}
}
namespace ExpediaBundle\Controller;
//...
class BookingController extends Controller {
/**
* @Route("/expedia/booking", name="expedia_booking")
* @Template()
*/
public function indexAction(Request $request)
{
\dump($request); // dumper 2
// The dumper 1 === dumper 2
return array();
}
}
{# file: ExpediaBundle:Booking:index.html.twig #}
{{ dump(app.request.attributes.get('_route_params')) }} -> works fine
{{ dump(app.request.get('_route_params')) }} -> works fine
When I enter to the route http://localhost/expedia/booking (without the forward) I can see the _route_params dumps correctly. But if I use the forward controller the varDumper returns null for both cases.
http://localhost/book/hotel/hotelname:
{{ dump(app.request.attributes.get('_route_params')) }} -> null
{{ dump(app.request.get('_route_params')) }} -> null
What am I doing wrong?
Thank you in advanced.