class RedirectController implements ContainerAwareInterface

Redirects a request to another URL.

Traits

ContainerAware trait.

Methods

setContainer(ContainerInterface $container = null)

Sets the container.

redirectAction(Request $request, string $route, bool $permanent = false, bool|array $ignoreAttributes = false)

Redirects to another route with the given name.

urlRedirectAction(Request $request, string $path, bool $permanent = false, string|null $scheme = null, int|null $httpPort = null, int|null $httpsPort = null)

Redirects to a URL.

Details

in ContainerAwareTrait at line line 31
setContainer(ContainerInterface $container = null)

Sets the container.

Parameters

ContainerInterface $container A ContainerInterface instance or null

at line line 49
Response redirectAction(Request $request, string $route, bool $permanent = false, bool|array $ignoreAttributes = false)

Redirects to another route with the given name.

The response status code is 302 if the permanent parameter is false (default), and 301 if the redirection is permanent.

In case the route name is empty, the status code will be 404 when permanent is false and 410 otherwise.

Parameters

Request $request The request instance
string $route The route name to redirect to
bool $permanent Whether the redirection is permanent
bool|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore

Return Value

Response A Response instance

Exceptions

HttpException In case the route name is empty

at line line 87
Response urlRedirectAction(Request $request, string $path, bool $permanent = false, string|null $scheme = null, int|null $httpPort = null, int|null $httpsPort = null)

Redirects to a URL.

The response status code is 302 if the permanent parameter is false (default), and 301 if the redirection is permanent.

In case the path is empty, the status code will be 404 when permanent is false and 410 otherwise.

Parameters

Request $request The request instance
string $path The absolute path or URL to redirect to
bool $permanent Whether the redirect is permanent or not
string|null $scheme The URL scheme (null to keep the current one)
int|null $httpPort The HTTP port (null to keep the current one for the same scheme or the configured port in the container)
int|null $httpsPort The HTTPS port (null to keep the current one for the same scheme or the configured port in the container)

Return Value

Response A Response instance

Exceptions

HttpException In case the path is empty