File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1111
1212namespace FOS \RestBundle \Controller ;
1313
14+ use FOS \RestBundle \Util \StopFormatListenerException ;
1415use FOS \RestBundle \View \ExceptionWrapperHandlerInterface ;
1516use Symfony \Bundle \FrameworkBundle \Templating \TemplateReference ;
1617use Symfony \Component \HttpKernel \Exception \FlattenException as HttpFlattenException ;
@@ -209,9 +210,13 @@ protected function getStatusCode($exception)
209210 */
210211 protected function getFormat (Request $ request , $ format )
211212 {
212- $ formatNegotiator = $ this ->container ->get ('fos_rest.format_negotiator ' );
213- $ format = $ formatNegotiator ->getBestFormat ($ request ) ?: $ format ;
214- $ request ->attributes ->set ('_format ' , $ format );
213+ try {
214+ $ formatNegotiator = $ this ->container ->get ('fos_rest.format_negotiator ' );
215+ $ format = $ formatNegotiator ->getBestFormat ($ request ) ?: $ format ;
216+ $ request ->attributes ->set ('_format ' , $ format );
217+ } catch (StopFormatListenerException $ e ) {
218+ $ format = $ request ->getRequestFormat ();
219+ }
215220
216221 return $ format ;
217222 }
You can’t perform that action at this time.
0 commit comments