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) Создаёт объект Request. | |
| bool | checkRequestPath(Request $request, string $path) Проверяет, соответствует ли заданный путь объекту Request. | |
| string | generateUri(Request $request, string $path) Генерирует URI на основе заданного пути или абсолютного URL. |
Подробности
__construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface|RequestMatcherInterface $urlMatcher = null)
Конструктор.
Параметры
| UrlGeneratorInterface | $urlGenerator | Экземпляр UrlGeneratorInterface |
| UrlMatcherInterface|RequestMatcherInterface | $urlMatcher | Матчер URL или Request |
Исключения
| 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 | Текущий объект Request |
| string | $path | Путь (абсолютный путь (/foo), абсолютный URL (http://...), или имя маршрута (foo)) |
Значение результата
| Request | Объект Request |
bool checkRequestPath(Request $request, string $path)
Проверяет, соответствует ли заданный путь объекту Request.
Параметры
| Request | $request | Объект Request |
| string | $path | Путь (абсолютный путь (/foo), абсолютный URL (http://...), или имя маршрута (foo)) |
Значение результата
| bool | true, если путь совпадает с путём из Request, иначе 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.0/Symfony/Component/Security/Http/HttpUtils.html