HttpUtils
class HttpUtils
Encapsulates the logic needed to create sub-requests, redirect the user, and match URLs.
Methods
__construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface|RequestMatcherInterface $urlMatcher = null, string|null $domainRegexp = null) | ||
RedirectResponse | createRedirectResponse(Request $request, string $path, int $status = 302) Creates a redirect Response. | |
Request | createRequest(Request $request, string $path) Creates a Request. | |
bool | checkRequestPath(Request $request, string $path) Checks that a given path matches the Request. | |
string | generateUri(Request $request, string $path) Generates a URI, based on the given path or absolute URL. |
Details
__construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface|RequestMatcherInterface $urlMatcher = null, string|null $domainRegexp = null)
Parameters
UrlGeneratorInterface | $urlGenerator | A UrlGeneratorInterface instance |
UrlMatcherInterface|RequestMatcherInterface | $urlMatcher | The URL or Request matcher |
string|null | $domainRegexp | A regexp that the target of HTTP redirections must match, scheme included |
Exceptions
InvalidArgumentException |
RedirectResponse createRedirectResponse(Request $request, string $path, int $status = 302)
Creates a redirect Response.
Parameters
Request | $request | A Request instance |
string | $path | A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) |
int | $status | The status code |
Return Value
RedirectResponse | A RedirectResponse instance |
Request createRequest(Request $request, string $path)
Creates a Request.
Parameters
Request | $request | The current Request instance |
string | $path | A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) |
Return Value
Request | A Request instance |
bool checkRequestPath(Request $request, string $path)
Checks that a given path matches the Request.
Parameters
Request | $request | A Request instance |
string | $path | A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) |
Return Value
bool | true if the path is the same as the one from the Request, false otherwise |
string generateUri(Request $request, string $path)
Generates a URI, based on the given path or absolute URL.
Parameters
Request | $request | A Request instance |
string | $path | A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) |
Return Value
string | An absolute URL |
Exceptions
LogicException |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/Security/Http/HttpUtils.html