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 $domainRegexp = null, string $secureDomainRegexp = null)

No description

createRedirectResponse(Request $request, string $path, int $status = 302)

Creates a redirect Response.

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

at line 43
__construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface|RequestMatcherInterface $urlMatcher = null, string $domainRegexp = null, string $secureDomainRegexp = null)

Parameters

UrlGeneratorInterface $urlGenerator A UrlGeneratorInterface instance
UrlMatcherInterface|RequestMatcherInterface $urlMatcher The URL or Request matcher
string $domainRegexp A regexp the target of HTTP redirections must match, scheme included
string $secureDomainRegexp A regexp the target of HTTP redirections must match when the scheme is "https"

Exceptions

InvalidArgumentException

at line 63
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

at line 83
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

at line 122
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

at line 154
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