RedirectController
class RedirectController implements ContainerAwareInterface
Перенаправляет запрос на другой URL.
Методы
| __construct(UrlGeneratorInterface $router = null, $httpPort = null, $httpsPort = null) | ||
| setContainer(ContainerInterface $container = null) устаревшее | ||
| Response | redirectAction(Request $request, string $route, bool $permanent = false, bool|array $ignoreAttributes = false) Перенаправляет на другой маршрут с заданным именем. | |
| Response | urlRedirectAction(Request $request, string $path, bool $permanent = false, string|null $scheme = null, int|null $httpPort = null, int|null $httpsPort = null) Перенаправляет на URL. |
Подробности
__construct(UrlGeneratorInterface $router = null, $httpPort = null, $httpsPort = null)
Параметры
| UrlGeneratorInterface | $router | |
| $httpPort | ||
| $httpsPort |
setContainer(ContainerInterface $container = null) устаревшее
устаревшее
Параметры
| ContainerInterface | $container |
Response redirectAction(Request $request, string $route, bool $permanent = false, bool|array $ignoreAttributes = false)
Перенаправляет на другой маршрут с заданным именем.
Код ответа — 302, если параметр permanent ложный (по умолчанию), и 301, если перенаправление постоянное.
Если имя маршрута пустое, код ответа будет 404, если permanent ложный, и 410 в противном случае.
Параметры
| Request | $request | Экземпляр запроса |
| string | $route | Имя маршрута для перенаправления |
| bool | $permanent | Является ли перенаправление постоянным |
| bool|array | $ignoreAttributes | Игнорировать атрибуты или массив атрибутов для игнорирования |
Возвращаемое значение
| Response | Экземпляр Response |
Исключения
| HttpException | В случае пустого имени маршрута |
Response urlRedirectAction(Request $request, string $path, bool $permanent = false, string|null $scheme = null, int|null $httpPort = null, int|null $httpsPort = null)
Перенаправляет на URL.
Код ответа — 302, если параметр permanent ложный (по умолчанию), и 301, если перенаправление постоянное.
Если путь пустой, код ответа будет 404, если permanent ложный, и 410 в противном случае.
Параметры
| Request | $request | Экземпляр запроса |
| string | $path | Абсолютный путь или URL для перенаправления |
| bool | $permanent | Перенаправление постоянное или нет |
| string|null | $scheme | Схема URL (null, чтобы сохранить текущую) |
| int|null | $httpPort | Порт HTTP (null, чтобы сохранить текущий для той же схемы или настроенный порт в контейнере) |
| int|null | $httpsPort | Порт HTTPS (null, чтобы сохранить текущий для той же схемы или настроенный порт в контейнере) |
Возвращаемое значение
| Response | Экземпляр Response |
Исключения
| HttpException | В случае пустого пути |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.4/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.html