I would like to change how symfony manages exception. When I have an exception (in html mode), I would like to replay the last action with a flash message.
For that I created a PostActionListener which listens kernel.response, where I saved the current request Object in session :
(<tag name="kernel.event_listener" event="kernel.response" method="saveHtmlRequestOnCoreResponse" />)
In the next action, if an error occurs, I would like to replay the last action with a flash message.
For the moment, I redefine my own exception Controller and I replay the action like that :
- Code: Select all
$response = $this->container->get('http_kernel')->forward($lastRequest->get('_controller'));
But I think it's not the good solution, because the state of the request is incomplete, indeed there are no post parameters.
Is it possible to re-execute it in the same context ?
Or is it possible to get the post parameter from the request object and pass it to the forward method? The Request class has a get method, but It's not designed to get all parameters.
Thanks for your help.