|
|
@@ -684,10 +684,14 @@ class Controller implements EventListenerInterface, EventDispatcherInterface
|
|
|
{
|
|
|
$this->autoRender = false;
|
|
|
|
|
|
- if ($status) {
|
|
|
- $this->response = $this->response->withStatus($status);
|
|
|
+ if ($status < 300 || $status > 399) {
|
|
|
+ throw new InvalidArgumentException(
|
|
|
+ sprintf('Invalid status code `%s`. It should be within the range ' .
|
|
|
+ '`300` - `399` for redirect responses.', $status)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
+ $this->response = $this->response->withStatus($status);
|
|
|
$event = $this->dispatchEvent('Controller.beforeRedirect', [$url, $this->response]);
|
|
|
if ($event->getResult() instanceof Response) {
|
|
|
return $this->response = $event->getResult();
|