UrlGenerator
class UrlGenerator implements UrlGenerator
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 | $forcedRoot | The forced URL root. |
|
protected string | $forceScheme | The forced schema for URLs. |
|
protected string|null | $cachedRoot | A cached copy of the URL root for the current request. |
|
protected string|null | $cachedSchema | A cached copy of the URL schema for the current request. |
|
protected string | $rootNamespace | The root namespace being applied to controller actions. |
|
protected callable | $sessionResolver | The session resolver callable. |
|
protected Closure | $formatHostUsing | The callback to use to format hosts. |
|
protected Closure | $formatPathUsing | The callback to use to format paths. |
|
protected RouteUrlGenerator | $routeGenerator | The route URL generator instance. |
Methods
Dynamically handle calls to the class.
Dynamically handle calls to the class.
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.
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.
Format the given URL segments into a single URL.
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.
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 root controller namespace.
Details
in
Macroable at line 24
static void
macro(string $name, callable $macro)
Register a custom macro.
in
Macroable at line 35
static bool
hasMacro(string $name)
Checks if macro is registered.
in
Macroable at line 49
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 71
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 101
void
__construct(RouteCollection $routes, Request $request)
Create a new URL Generator instance.
at line 113
string
full()
Get the full URL for the current request.
at line 123
string
current()
Get the current URL for the request.
at line 134
string
previous(mixed $fallback = false)
Get the URL for the previous request.
at line 154
protected string|null
getPreviousUrlFromSession()
Get the previous URL from the session if possible.
at line 169
string
to(string $path, mixed $extra = [], bool $secure = null)
Generate an absolute URL to the given path.
at line 201
string
secure(string $path, array $parameters = [])
Generate a secure, absolute URL to the given path.
at line 213
string
asset(string $path, bool $secure = null)
Generate the URL to an application asset.
at line 233
string
secureAsset(string $path)
Generate the URL to a secure asset.
at line 246
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 262
protected string
removeIndex(string $root)
Remove the index.php file from a path.
at line 275
string
formatScheme(bool|null $secure)
Get the default scheme for a raw URL.
at line 298
string
route(string $name, mixed $parameters = [], bool $absolute = true)
Get the URL to a named route.
at line 317
protected string
toRoute(Route $route, mixed $parameters, bool $absolute)
Get the URL for a given route instance.
at line 334
string
action(string $action, mixed $parameters = [], bool $absolute = true)
Get the URL to a controller action.
at line 349
protected string
formatAction(string $action)
Format the given controller action.
at line 364
array
formatParameters(mixed|array $parameters)
Format the array of URL parameters.
at line 383
protected array
extractQueryString(string $path)
Extract the query string from the given path.
at line 402
string
formatRoot(string $scheme, string $root = null)
Get the base URL for the request.
at line 424
string
format(string $root, string $path)
Format the given URL segments into a single URL.
at line 445
bool
isValidUrl(string $path)
Determine if the given path is a valid URL.
at line 459
protected RouteUrlGenerator
routeUrl()
Get the Route URL generator instance.
at line 474
void
defaults(array $defaults)
Set the default named parameters used by the URL generator.
at line 485
void
forceScheme(string $schema)
Force the scheme for URLs.
at line 498
void
forceRootUrl(string $root)
Set the forced root URL.
at line 511
$this
formatHostUsing(Closure $callback)
Set a callback to be used to format the host of generated URLs.
at line 524
$this
formatPathUsing(Closure $callback)
Set a callback to be used to format the path of generated URLs.
at line 536
Closure
pathFormatter()
Get the path formatter being used by the URL generator.
at line 548
Request
getRequest()
Get the request instance.
at line 559
void
setRequest(Request $request)
Set the current request instance.
at line 574
$this
setRoutes(RouteCollection $routes)
Set the route collection.
at line 586
protected Store|null
getSession()
Get the session implementation from the resolver.
at line 599
$this
setSessionResolver(callable $sessionResolver)
Set the session resolver for the generator.
at line 612
$this
setRootControllerNamespace(string $rootNamespace)
Set the root controller namespace.