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)

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 line 41
__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

at line line 60
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 line 77
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 line 105
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 line 137
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