UrlGenerator
class UrlGenerator implements UrlGenerator (View source)
Traits
Properties
static protected array | $macros | The registered string macros. | from Macroable |
protected RouteCollection | $routes | The route collection. | |
protected Request | $request | The request instance. | |
protected string | $assetRoot | The asset root URL. | |
protected string | $forcedRoot | The forced URL root. | |
protected string | $forceScheme | The forced scheme for URLs. | |
protected string|null | $cachedRoot | A cached copy of the URL root for the current request. | |
protected string|null | $cachedScheme | A cached copy of the URL scheme for the current request. | |
protected string | $rootNamespace | The root namespace being applied to controller actions. | |
protected callable | $sessionResolver | The session resolver callable. | |
protected callable | $keyResolver | The encryption key resolver callable. | |
protected Closure | $formatHostUsing | The callback to use to format hosts. | |
protected Closure | $formatPathUsing | The callback to use to format paths. | |
protected RouteUrlGenerator|null | $routeGenerator | The route URL generator instance. |
Methods
Get the number of seconds until the given DateTime.
If the given value is an interval, convert it to a DateTime instance.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new URL Generator instance.
Get the full URL for the current request.
Get the current URL for the request.
Get the URL for the previous request.
Get the previous URL from the session if possible.
Generate an absolute URL to the given path.
Generate a secure, absolute URL to the given path.
Generate the URL to an application asset.
Generate the URL to a secure asset.
Generate the URL to an asset from a custom root domain such as CDN, etc.
Remove the index.php file from a path.
Get the default scheme for a raw URL.
Create a signed route URL for a named route.
Create a temporary signed route URL for a named route.
Determine if the given request has a valid signature.
Determine if the signature from the given request matches the URL.
Determine if the expires timestamp from the given request is not from the past.
Get the URL to a named route.
Get the URL to a controller action.
Format the given controller action.
Format the array of URL parameters.
Extract the query string from the given path.
Get the base URL for the request.
Determine if the given path is a valid URL.
Get the Route URL generator instance.
Set the default named parameters used by the URL generator.
Get the default named parameters used by the URL generator.
Force the scheme for URLs.
Set the forced root URL.
Get the path formatter being used by the URL generator.
Get the request instance.
Get the session implementation from the resolver.
Set the session resolver for the generator.
Set the encryption key resolver.
Set the root controller namespace.
Details
in InteractsWithTime at line 16
protected int
secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime.
in InteractsWithTime at line 31
protected int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp.
in InteractsWithTime at line 46
protected DateTimeInterface|int
parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance.
in InteractsWithTime at line 60
protected int
currentTime()
Get the current system time as a UNIX timestamp.
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 120
void
__construct(RouteCollection $routes, Request $request, string|null $assetRoot = null)
Create a new URL Generator instance.
at line 133
string
full()
Get the full URL for the current request.
at line 143
string
current()
Get the current URL for the request.
at line 154
string
previous(mixed $fallback = false)
Get the URL for the previous request.
at line 174
protected string|null
getPreviousUrlFromSession()
Get the previous URL from the session if possible.
at line 189
string
to(string $path, mixed $extra = [], bool|null $secure = null)
Generate an absolute URL to the given path.
at line 221
string
secure(string $path, array $parameters = [])
Generate a secure, absolute URL to the given path.
at line 233
string
asset(string $path, bool|null $secure = null)
Generate the URL to an application asset.
at line 255
string
secureAsset(string $path)
Generate the URL to a secure asset.
at line 268
string
assetFrom(string $root, string $path, bool|null $secure = null)
Generate the URL to an asset from a custom root domain such as CDN, etc.
at line 284
protected string
removeIndex(string $root)
Remove the index.php file from a path.
at line 297
string
formatScheme(bool|null $secure = null)
Get the default scheme for a raw URL.
at line 321
string
signedRoute(string $name, array $parameters = [], DateTimeInterface|DateInterval|int|null $expiration = null, bool $absolute = true)
Create a signed route URL for a named route.
at line 353
string
temporarySignedRoute(string $name, DateTimeInterface|DateInterval|int $expiration, array $parameters = [], bool $absolute = true)
Create a temporary signed route URL for a named route.
at line 365
bool
hasValidSignature(Request $request, bool $absolute = true)
Determine if the given request has a valid signature.
at line 378
bool
hasCorrectSignature(Request $request, bool $absolute = true)
Determine if the signature from the given request matches the URL.
at line 397
bool
signatureHasNotExpired(Request $request)
Determine if the expires timestamp from the given request is not from the past.
at line 414
string
route(string $name, mixed $parameters = [], bool $absolute = true)
Get the URL to a named route.
at line 433
string
toRoute(Route $route, mixed $parameters, bool $absolute)
Get the URL for a given route instance.
at line 450
string
action(string|array $action, mixed $parameters = [], bool $absolute = true)
Get the URL to a controller action.
at line 465
protected string
formatAction(string|array $action)
Format the given controller action.
at line 484
array
formatParameters(mixed|array $parameters)
Format the array of URL parameters.
at line 503
protected array
extractQueryString(string $path)
Extract the query string from the given path.
at line 522
string
formatRoot(string $scheme, string|null $root = null)
Get the base URL for the request.
at line 545
string
format(string $root, string $path, Route|null $route = null)
Format the given URL segments into a single URL.
at line 566
bool
isValidUrl(string $path)
Determine if the given path is a valid URL.
at line 580
protected RouteUrlGenerator
routeUrl()
Get the Route URL generator instance.
at line 595
void
defaults(array $defaults)
Set the default named parameters used by the URL generator.
at line 605
array
getDefaultParameters()
Get the default named parameters used by the URL generator.
at line 616
void
forceScheme(string $scheme)
Force the scheme for URLs.
at line 629
void
forceRootUrl(string $root)
Set the forced root URL.
at line 642
$this
formatHostUsing(Closure $callback)
Set a callback to be used to format the host of generated URLs.
at line 655
$this
formatPathUsing(Closure $callback)
Set a callback to be used to format the path of generated URLs.
at line 705
$this
setRoutes(RouteCollection $routes)
Set the route collection.
at line 730
$this
setSessionResolver(callable $sessionResolver)
Set the session resolver for the generator.
at line 743
$this
setKeyResolver(callable $keyResolver)
Set the encryption key resolver.
at line 756
$this
setRootControllerNamespace(string $rootNamespace)
Set the root controller namespace.