This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

handle exceptions differently

About symfony tutorials, symfony book and API documentation.

handle exceptions differently

by supernano » Mon Apr 02, 2012 9:52 am

Hello,

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.

Michel
supernano
Junior Member
 
Posts: 3
Joined: Mon Feb 20, 2012 3:47 pm