HttpUtils
class HttpUtils
Инкапсулирует логику, необходимую для создания подзапросов, перенаправления пользователя и сопоставления URL-адресов.
Методы
| __construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface|RequestMatcherInterface $urlMatcher = null) Конструктор. | ||
| RedirectResponse | createRedirectResponse(Request $request, string $path, int $status = 302) Создаёт ответ перенаправления. | |
| Request | createRequest(Request $request, string $path) Создаёт запрос. | |
| bool | checkRequestPath(Request $request, string $path) Проверяет, соответствует ли заданный путь запросу. | |
| string | generateUri(Request $request, string $path) Генерирует URI на основе заданного пути или абсолютного URL-адреса. |
Подробности
__construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface|RequestMatcherInterface $urlMatcher = null)
Конструктор.
Параметры
| UrlGeneratorInterface | $urlGenerator | Экземпляр UrlGeneratorInterface |
| UrlMatcherInterface|RequestMatcherInterface | $urlMatcher | Сопоставитель URL-адреса или запроса |
Исключения
| InvalidArgumentException |
RedirectResponse createRedirectResponse(Request $request, string $path, int $status = 302)
Создаёт ответ перенаправления.
Параметры
| Request | $request | Экземпляр Request |
| string | $path | Путь (абсолютный путь (/foo), абсолютный URL (http://...), или имя маршрута (foo)) |
| int | $status | Код состояния |
Возвращаемое значение
| RedirectResponse | Экземпляр RedirectResponse |
Request createRequest(Request $request, string $path)
Создаёт запрос.
Параметры
| Request | $request | Текущий экземпляр Request |
| string | $path | Путь (абсолютный путь (/foo), абсолютный URL (http://...), или имя маршрута (foo)) |
Возвращаемое значение
| Request | Экземпляр Request |
bool checkRequestPath(Request $request, string $path)
Проверяет, соответствует ли заданный путь запросу.
Параметры
| Request | $request | Экземпляр Request |
| string | $path | Путь (абсолютный путь (/foo), абсолютный URL (http://...), или имя маршрута (foo)) |
Возвращаемое значение
| bool | true, если путь совпадает с путём из запроса, иначе false |
string generateUri(Request $request, string $path)
Генерирует URI на основе заданного пути или абсолютного URL-адреса.
Параметры
| Request | $request | Экземпляр Request |
| string | $path | Путь (абсолютный путь (/foo), абсолютный URL (http://...), или имя маршрута (foo)) |
Возвращаемое значение
| string | Абсолютный URL-адрес |
Исключения
| LogicException |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.1/Symfony/Component/Security/Http/HttpUtils.html