class UrlGenerator implements UrlGenerator (View source)

Traits

Methods

static void
macro(string $name, callable $macro)

Register a custom macro.

from Macroable
static bool
hasMacro(string $name)

Checks if macro is registered.

from Macroable
static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
void
__construct(RouteCollection $routes, Request $request)

Create a new URL Generator instance.

string
full()

Get the full URL for the current request.

string
current()

Get the current URL for the request.

string
previous(mixed $fallback = false)

Get the URL for the previous request.

string
to(string $path, mixed $extra = array(), bool $secure = null)

Generate an absolute URL to the given path.

string
secure(string $path, array $parameters = array())

Generate a secure, absolute URL to the given path.

string
asset(string $path, bool $secure = null)

Generate the URL to an application asset.

string
secureAsset(string $path)

Generate the URL to a secure asset.

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.

string
formatScheme(bool|null $secure)

Get the default scheme for a raw URL.

string
route(string $name, mixed $parameters = array(), bool $absolute = true)

Get the URL to a named route.

string
action(string $action, mixed $parameters = array(), bool $absolute = true)

Get the URL to a controller action.

array
formatParameters(mixed|array $parameters)

Format the array of URL parameters.

string
formatRoot(string $scheme, string $root = null)

Get the base URL for the request.

string
format(string $root, string $path)

Format the given URL segments into a single URL.

bool
isValidUrl(string $path)

Determine if the given path is a valid URL.

void
defaults(array $defaults)

Set the default named parameters used by the URL generator.

void
forceScheme(string $schema)

Force the scheme for URLs.

void
forceRootUrl(string $root)

Set the forced root URL.

$this
formatHostUsing(Closure $callback)

Set a callback to be used to format the host of generated URLs.

$this
formatPathUsing(Closure $callback)

Set a callback to be used to format the path of generated URLs.

pathFormatter()

Get the path formatter being used by the URL generator.

getRequest()

Get the request instance.

void
setRequest(Request $request)

Set the current request instance.

$this
setRoutes(RouteCollection $routes)

Set the route collection.

$this
setSessionResolver(callable $sessionResolver)

Set the session resolver for the generator.

$this
setRootControllerNamespace(string $rootNamespace)

Set the root controller namespace.

Details

in Macroable at line line 24
static void macro(string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

in Macroable at line line 35
static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line line 49
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line line 71
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line line 101
void __construct(RouteCollection $routes, Request $request)

Create a new URL Generator instance.

Parameters

RouteCollection $routes
Request $request

Return Value

void

at line line 113
string full()

Get the full URL for the current request.

Return Value

string

at line line 123
string current()

Get the current URL for the request.

Return Value

string

at line line 134
string previous(mixed $fallback = false)

Get the URL for the previous request.

Parameters

mixed $fallback

Return Value

string

at line line 169
string to(string $path, mixed $extra = array(), bool $secure = null)

Generate an absolute URL to the given path.

Parameters

string $path
mixed $extra
bool $secure

Return Value

string

at line line 201
string secure(string $path, array $parameters = array())

Generate a secure, absolute URL to the given path.

Parameters

string $path
array $parameters

Return Value

string

at line line 213
string asset(string $path, bool $secure = null)

Generate the URL to an application asset.

Parameters

string $path
bool $secure

Return Value

string

at line line 233
string secureAsset(string $path)

Generate the URL to a secure asset.

Parameters

string $path

Return Value

string

at line 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.

Parameters

string $root
string $path
bool|null $secure

Return Value

string

at line line 275
string formatScheme(bool|null $secure)

Get the default scheme for a raw URL.

Parameters

bool|null $secure

Return Value

string

at line line 298
string route(string $name, mixed $parameters = array(), bool $absolute = true)

Get the URL to a named route.

Parameters

string $name
mixed $parameters
bool $absolute

Return Value

string

Exceptions

InvalidArgumentException

at line line 334
string action(string $action, mixed $parameters = array(), bool $absolute = true)

Get the URL to a controller action.

Parameters

string $action
mixed $parameters
bool $absolute

Return Value

string

Exceptions

InvalidArgumentException

at line line 364
array formatParameters(mixed|array $parameters)

Format the array of URL parameters.

Parameters

mixed|array $parameters

Return Value

array

at line line 402
string formatRoot(string $scheme, string $root = null)

Get the base URL for the request.

Parameters

string $scheme
string $root

Return Value

string

at line line 424
string format(string $root, string $path)

Format the given URL segments into a single URL.

Parameters

string $root
string $path

Return Value

string

at line line 445
bool isValidUrl(string $path)

Determine if the given path is a valid URL.

Parameters

string $path

Return Value

bool

at line line 474
void defaults(array $defaults)

Set the default named parameters used by the URL generator.

Parameters

array $defaults

Return Value

void

at line line 485
void forceScheme(string $schema)

Force the scheme for URLs.

Parameters

string $schema

Return Value

void

at line line 498
void forceRootUrl(string $root)

Set the forced root URL.

Parameters

string $root

Return Value

void

at line line 511
$this formatHostUsing(Closure $callback)

Set a callback to be used to format the host of generated URLs.

Parameters

Closure $callback

Return Value

$this

at line line 524
$this formatPathUsing(Closure $callback)

Set a callback to be used to format the path of generated URLs.

Parameters

Closure $callback

Return Value

$this

at line line 536
Closure pathFormatter()

Get the path formatter being used by the URL generator.

Return Value

Closure

at line line 548
Request getRequest()

Get the request instance.

Return Value

Request

at line line 559
void setRequest(Request $request)

Set the current request instance.

Parameters

Request $request

Return Value

void

at line line 574
$this setRoutes(RouteCollection $routes)

Set the route collection.

Parameters

RouteCollection $routes

Return Value

$this

at line line 599
$this setSessionResolver(callable $sessionResolver)

Set the session resolver for the generator.

Parameters

callable $sessionResolver

Return Value

$this

at line line 612
$this setRootControllerNamespace(string $rootNamespace)

Set the root controller namespace.

Parameters

string $rootNamespace

Return Value

$this