Skip to content

Commit eefa714

Browse files
committed
minor #2209 clean up unreachable code (xabbuh)
This PR was merged into the 3.0-dev branch. Discussion ---------- clean up unreachable code Commits ------- 996272d clean up unreachable code
2 parents 0e6afd8 + 996272d commit eefa714

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

DependencyInjection/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ private function addViewSection(ArrayNodeDefinition $rootNode): void
177177
->arrayNode('view')
178178
->fixXmlConfig('format', 'formats')
179179
->fixXmlConfig('mime_type', 'mime_types')
180-
->fixXmlConfig('force_redirect', 'force_redirects')
181180
->addDefaultsIfNotSet()
182181
->children()
183182
->arrayNode('mime_types')

View/ViewHandler.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use FOS\RestBundle\Context\Context;
1515
use FOS\RestBundle\Serializer\Serializer;
1616
use Symfony\Component\Form\FormInterface;
17-
use Symfony\Component\HttpFoundation\RedirectResponse;
1817
use Symfony\Component\HttpFoundation\Request;
1918
use Symfony\Component\HttpFoundation\RequestStack;
2019
use 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

Comments
 (0)