class RouteUrlGenerator

Properties

protected UrlGenerator $url

The URL generator instance.

array $defaultParameters

The global named parameter defaults.

array $dontEncode

Characters that should not be URL encoded.

Methods

__construct(UrlGenerator $url)

Create a new route URL generator.

string
to(Route $route, mixed $parameters = [], bool $absolute = false)

Generate a URL for the given route.

string|null
getRouteDomain(Route $route, array $parameters)

Get the formatted domain for a given route.

string
formatDomain(Route $route, array $parameters)

Format the domain and port for the route and request.

string
getRouteScheme(Route $route)

Get the scheme for the given route.

string
addPortToDomain(string $domain, Route|null $route = null)

Add the port to the domain if necessary.

bool
isRouteSecure(Route $route)

Determine if the route uses HTTPS.

array
formatParameters(Route $route, mixed $parameters, array $defaultParameters)

Format the array of route parameters.

string
replaceRootParameters(Route $route, string|null $domain, array $parameters, array $defaultParameters)

Replace the parameters on the root path.

string
replacePortInRoot(string $root, Route $route)

Replace the port in a root URL with the route's configured port.

string
replaceRouteParameters(string $path, array $parameters, array $defaultParameters)

Replace all of the wildcard parameters for a route path.

string
replaceNamedParameters(string $path, array $parameters, array $defaultParameters)

Replace all of the named parameters in the path.

string
addQueryString(string $uri, array $parameters)

Add a query string to the URI.

string
getRouteQueryString(array $parameters)

Get the query string for a given route.

array
getStringParameters(array $parameters)

Get the string parameters from a given list.

array
getNumericParameters(array $parameters)

Get the numeric parameters from a given list.

void
defaults(array $defaults)

Set the default named parameters used by the URL generator.

Details

at line 51
__construct(UrlGenerator $url)

Create a new route URL generator.

Parameters

UrlGenerator $url

at line 61
string to(Route $route, mixed $parameters = [], bool $absolute = false)

Generate a URL for the given route.

Parameters

Route $route
mixed $parameters
bool $absolute

Return Value

string

Exceptions

UrlGenerationException

at line 102
protected string|null getRouteDomain(Route $route, array $parameters)

Get the formatted domain for a given route.

Parameters

Route $route
array $parameters

Return Value

string|null

at line 110
protected string formatDomain(Route $route, array $parameters)

Format the domain and port for the route and request.

Parameters

Route $route
array $parameters

Return Value

string

at line 121
protected string getRouteScheme(Route $route)

Get the scheme for the given route.

Parameters

Route $route

Return Value

string

at line 136
protected string addPortToDomain(string $domain, Route|null $route = null)

Add the port to the domain if necessary.

Parameters

string $domain
Route|null $route

Return Value

string

at line 152
protected bool isRouteSecure(Route $route)

Determine if the route uses HTTPS.

Parameters

Route $route

Return Value

bool

at line 168
protected array formatParameters(Route $route, mixed $parameters, array $defaultParameters)

Format the array of route parameters.

Parameters

Route $route
mixed $parameters
array $defaultParameters

Return Value

array

at line 299
protected string replaceRootParameters(Route $route, string|null $domain, array $parameters, array $defaultParameters)

Replace the parameters on the root path.

Parameters

Route $route
string|null $domain
array $parameters
array $defaultParameters

Return Value

string

at line 322
protected string replacePortInRoot(string $root, Route $route)

Replace the port in a root URL with the route's configured port.

Parameters

string $root
Route $route

Return Value

string

at line 342
protected string replaceRouteParameters(string $path, array $parameters, array $defaultParameters)

Replace all of the wildcard parameters for a route path.

Parameters

string $path
array $parameters
array $defaultParameters

Return Value

string

at line 364
protected string replaceNamedParameters(string $path, array $parameters, array $defaultParameters)

Replace all of the named parameters in the path.

Parameters

string $path
array $parameters
array $defaultParameters

Return Value

string

at line 387
protected string addQueryString(string $uri, array $parameters)

Add a query string to the URI.

Parameters

string $uri
array $parameters

Return Value

string

at line 404
protected string getRouteQueryString(array $parameters)

Get the query string for a given route.

Parameters

array $parameters

Return Value

string

at line 435
protected array getStringParameters(array $parameters)

Get the string parameters from a given list.

Parameters

array $parameters

Return Value

array

at line 443
protected array getNumericParameters(array $parameters)

Get the numeric parameters from a given list.

Parameters

array $parameters

Return Value

array

at line 451
void defaults(array $defaults)

Set the default named parameters used by the URL generator.

Parameters

array $defaults

Return Value

void