UrlGenerator
Implements
Uses
Properties
$assetRoot string
The asset root URL.
$forcedRoot string
The forced URL root.
$forceScheme string
The forced scheme for URLs.
$cachedRoot string|null
A cached copy of the URL root for the current request.
$cachedScheme string|null
A cached copy of the URL scheme for the current request.
$rootNamespace string
The root namespace being applied to controller actions.
$sessionResolver callable
The session resolver callable.
$keyResolver callable
The encryption key resolver callable.
Methods
__construct ( RouteCollectionInterface $routes , Request $request , $assetRoot ) : void
Create a new URL Generator instance.
Parameters
- $routes RouteCollectionInterface
- $request Request
- $assetRoot string|null
full ( ) : string
Get the full URL for the current request.
current ( ) : string
Get the current URL for the request.
previous ( $fallback ) : string
Get the URL for the previous request.
Parameters
- $fallback mixed
getPreviousUrlFromSession ( ) : string|null
Get the previous URL from the session if possible.
to ( $path , $extra , $secure ) : string
Generate an absolute URL to the given path.
Parameters
- $path string
- $extra mixed
- $secure bool|null
secure ( $path , $parameters ) : string
Generate a secure, absolute URL to the given path.
Parameters
- $path string
- $parameters array
asset ( $path , $secure ) : string
Generate the URL to an application asset.
Parameters
- $path string
- $secure bool|null
secureAsset ( $path ) : string
Generate the URL to a secure asset.
Parameters
- $path string
assetFrom ( $root , $path , $secure ) : string
Generate the URL to an asset from a custom root domain such as CDN, etc.
Parameters
- $root string
- $path string
- $secure bool|null
removeIndex ( $root ) : string
Remove the index.php file from a path.
Parameters
- $root string
formatScheme ( $secure ) : string
Get the default scheme for a raw URL.
Parameters
- $secure bool|null
signedRoute ( $name , $parameters , $expiration , $absolute ) : string
Create a signed route URL for a named route.
Parameters
- $name string
- $parameters mixed
- $expiration DateTimeInterface |DateInterval |int|null
- $absolute bool
ensureSignedRouteParametersAreNotReserved ( $parameters ) : void
Ensure the given signed route parameters are not reserved.
Parameters
- $parameters mixed
temporarySignedRoute ( $name , $expiration , $parameters , $absolute ) : string
Create a temporary signed route URL for a named route.
Parameters
- $name string
- $expiration DateTimeInterface |DateInterval |int
- $parameters array
- $absolute bool
hasValidSignature ( Request $request , $absolute ) : bool
Determine if the given request has a valid signature.
Parameters
- $request Request
- $absolute bool
hasValidRelativeSignature ( Request $request ) : bool
Determine if the given request has a valid signature for a relative URL.
Parameters
- $request Request
hasCorrectSignature ( Request $request , $absolute ) : bool
Determine if the signature from the given request matches the URL.
Parameters
- $request Request
- $absolute bool
signatureHasNotExpired ( Request $request ) : bool
Determine if the expires timestamp from the given request is not from the past.
Parameters
- $request Request
route ( $name , $parameters , $absolute ) : string
Get the URL to a named route.
Parameters
- $name string
- $parameters mixed
- $absolute bool
toRoute ( $route , $parameters , $absolute ) : string
Get the URL for a given route instance.
Parameters
- $route Route
- $parameters mixed
- $absolute bool
action ( $action , $parameters , $absolute ) : string
Get the URL to a controller action.
Parameters
- $action string|array
- $parameters mixed
- $absolute bool
formatAction ( $action ) : string
Format the given controller action.
Parameters
- $action string|array
formatParameters ( $parameters ) : array
Format the array of URL parameters.
Parameters
- $parameters mixed|array
extractQueryString ( $path ) : array
Extract the query string from the given path.
Parameters
- $path string
formatRoot ( $scheme , $root ) : string
Get the base URL for the request.
Parameters
- $scheme string
- $root string|null
format ( $root , $path , $route ) : string
Format the given URL segments into a single URL.
Parameters
- $root string
- $path string
- $route Route |null
isValidUrl ( $path ) : bool
Determine if the given path is a valid URL.
Parameters
- $path string
defaults ( array $defaults ) : void
Set the default named parameters used by the URL generator.
Parameters
- $defaults array
getDefaultParameters ( ) : array
Get the default named parameters used by the URL generator.
forceScheme ( $scheme ) : void
Force the scheme for URLs.
Parameters
- $scheme string|null
forceRootUrl ( $root ) : void
Set the forced root URL.
Parameters
- $root string|null
formatHostUsing ( Closure $callback ) : $this
Set a callback to be used to format the host of generated URLs.
Parameters
- $callback Closure
formatPathUsing ( Closure $callback ) : $this
Set a callback to be used to format the path of generated URLs.
Parameters
- $callback Closure
setRequest ( Request $request ) : void
Set the current request instance.
Parameters
- $request Request
setRoutes ( RouteCollectionInterface $routes ) : $this
Set the route collection.
Parameters
- $routes RouteCollectionInterface
setSessionResolver ( callable $sessionResolver ) : $this
Set the session resolver for the generator.
Parameters
- $sessionResolver callable
setKeyResolver ( callable $keyResolver ) : $this
Set the encryption key resolver.
Parameters
- $keyResolver callable
setRootControllerNamespace ( $rootNamespace ) : $this
Set the root controller namespace.
Parameters
- $rootNamespace string