1414use FOS \RestBundle \Context \Context ;
1515use FOS \RestBundle \Serializer \Serializer ;
1616use Symfony \Component \Form \FormInterface ;
17- use Symfony \Component \HttpFoundation \RedirectResponse ;
1817use Symfony \Component \HttpFoundation \Request ;
1918use Symfony \Component \HttpFoundation \RequestStack ;
2019use Symfony \Component \HttpFoundation \Response ;
@@ -47,14 +46,6 @@ final class ViewHandler implements ConfigurableViewHandlerInterface
4746 private $ failedValidationCode ;
4847 private $ emptyContentCode ;
4948 private $ serializeNull ;
50-
51- /**
52- * If to force a redirect for the given key format,
53- * with value being the status code to use.
54- *
55- * @var array<string,int>
56- */
57- private $ forceRedirects ;
5849 private $ exclusionStrategyGroups = [];
5950 private $ exclusionStrategyVersion ;
6051 private $ serializeNullStrategy ;
@@ -71,7 +62,6 @@ private function __construct(
7162 int $ failedValidationCode = Response::HTTP_BAD_REQUEST ,
7263 int $ emptyContentCode = Response::HTTP_NO_CONTENT ,
7364 bool $ serializeNull = false ,
74- array $ forceRedirects = null ,
7565 array $ options = []
7666 ) {
7767 $ this ->urlGenerator = $ urlGenerator ;
@@ -81,7 +71,6 @@ private function __construct(
8171 $ this ->failedValidationCode = $ failedValidationCode ;
8272 $ this ->emptyContentCode = $ emptyContentCode ;
8373 $ this ->serializeNull = $ serializeNull ;
84- $ this ->forceRedirects = (array ) $ forceRedirects ;
8574 $ this ->options = $ options + [
8675 'exclusionStrategyGroups ' => [],
8776 'exclusionStrategyVersion ' => null ,
@@ -101,7 +90,7 @@ public static function create(
10190 array $ options = []
10291 ): self
10392 {
104- return new self ($ urlGenerator , $ serializer , $ requestStack , $ formats , $ failedValidationCode , $ emptyContentCode , $ serializeNull , [], $ options , false );
93+ return new self ($ urlGenerator , $ serializer , $ requestStack , $ formats , $ failedValidationCode , $ emptyContentCode , $ serializeNull , $ options , false );
10594 }
10695
10796 /**
@@ -177,15 +166,9 @@ public function createRedirectResponse(View $view, string $location, string $for
177166 $ response = $ this ->initResponse ($ view , $ format );
178167 } else {
179168 $ response = $ view ->getResponse ();
180- if ('html ' === $ format && isset ($ this ->forceRedirects [$ format ])) {
181- $ redirect = new RedirectResponse ($ location );
182- $ content = $ redirect ->getContent ();
183- $ response ->setContent ($ content );
184- }
185169 }
186170
187- $ code = isset ($ this ->forceRedirects [$ format ])
188- ? $ this ->forceRedirects [$ format ] : $ this ->getStatusCode ($ view , $ content );
171+ $ code = $ this ->getStatusCode ($ view , $ content );
189172
190173 $ response ->setStatusCode ($ code );
191174 $ response ->headers ->set ('Location ' , $ location );
0 commit comments