UrlGenerator
class UrlGenerator implements UrlGenerator (View source)
Traits
Macroable |
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 | $forceSchema | 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 array | $dontEncode | Characters that should not be URL encoded. |
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() Get the URL for the previous request. | |
string | to(string $path, mixed $extra = [], bool $secure = null) Generate an absolute URL to the given path. | |
string | secure(string $path, array $parameters = []) Generate a secure, absolute URL to the given path. | |
string | asset(string $path, bool $secure = null) Generate a URL to an application asset. | |
string | assetFrom(string $root, string $path, bool|null $secure = null) Generate a URL to an asset from a custom root domain such as CDN, etc. | |
string | removeIndex(string $root) Remove the index.php file from a path. | |
string | secureAsset(string $path) Generate a URL to a secure asset. | |
string | getScheme(bool|null $secure) Get the scheme for a raw URL. | |
void | forceSchema(string $schema) Force the schema for URLs. | |
string | route(string $name, mixed $parameters = [], bool $absolute = true) Get the URL to a named route. | |
string | toRoute(Route $route, mixed $parameters, bool $absolute) Get the URL for a given route instance. | |
string | replaceRoot(Route $route, string $domain, array $parameters) Replace the parameters on the root path. | |
string | replaceRouteParameters(string $path, array $parameters) Replace all of the wildcard parameters for a route path. | |
string | replaceNamedParameters(string $path, array $parameters) Replace all of the named parameters in the path. | |
mixed|string | addQueryString(string $uri, array $parameters) Add a query string to the URI. | |
array | formatParameters(mixed|array $parameters) Format the array of URL parameters. | |
array | replaceRoutableParameters(array $parameters = []) Replace UrlRoutable parameters with their route parameter. | |
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. | |
string | 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 | getDomainAndScheme(Route $route) Get the domain and scheme for the route. | |
string | addPortToDomain(string $domain) Add the port to the domain if necessary. | |
string | getRouteRoot(Route $route, string $domain) Get the root of the route URL. | |
string | getRouteScheme(Route $route) Get the scheme for the given route. | |
string | action(string $action, mixed $parameters = [], bool $absolute = true) Get the URL to a controller action. | |
string | getRootUrl(string $scheme, string $root = null) Get the base URL for the request. | |
void | forceRootUrl(string $root) Set the forced root URL. | |
bool | isValidUrl(string $path) Determine if the given path is a valid URL. | |
string | trimUrl(string $root, string $path, string $tail = '') Format the given URL segments into a single URL. | |
Request | getRequest() Get the request instance. | |
void | setRequest(Request $request) Set the current request instance. | |
$this | setRoutes(RouteCollection $routes) Set the route collection. | |
string|null | getPreviousUrlFromSession() Get the previous URL from the session if possible. | |
Store|null | getSession() Get the session implementation from the resolver. | |
$this | setSessionResolver(callable $sessionResolver) Set the session resolver for the generator. | |
$this | setRootControllerNamespace(string $rootNamespace) Set the root controller namespace. |
Details
static void macro(string $name, callable $macro)
Register a custom macro.
static bool hasMacro(string $name)
Checks if macro is registered.
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.
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()
Get the URL for the previous request.
string to(string $path, mixed $extra = [], bool $secure = null)
Generate an absolute URL to the given path.
string secure(string $path, array $parameters = [])
Generate a secure, absolute URL to the given path.
string asset(string $path, bool $secure = null)
Generate a URL to an application asset.
string assetFrom(string $root, string $path, bool|null $secure = null)
Generate a URL to an asset from a custom root domain such as CDN, etc.
protected string removeIndex(string $root)
Remove the index.php file from a path.
string secureAsset(string $path)
Generate a URL to a secure asset.
protected string getScheme(bool|null $secure)
Get the scheme for a raw URL.
void forceSchema(string $schema)
Force the schema for URLs.
string route(string $name, mixed $parameters = [], bool $absolute = true)
Get the URL to a named route.
protected string toRoute(Route $route, mixed $parameters, bool $absolute)
Get the URL for a given route instance.
protected string replaceRoot(Route $route, string $domain, array $parameters)
Replace the parameters on the root path.
protected string replaceRouteParameters(string $path, array $parameters)
Replace all of the wildcard parameters for a route path.
protected string replaceNamedParameters(string $path, array $parameters)
Replace all of the named parameters in the path.
protected mixed|string addQueryString(string $uri, array $parameters)
Add a query string to the URI.
protected array formatParameters(mixed|array $parameters)
Format the array of URL parameters.
protected array replaceRoutableParameters(array $parameters = [])
Replace UrlRoutable parameters with their route parameter.
protected string getRouteQueryString(array $parameters)
Get the query string for a given route.
protected array getStringParameters(array $parameters)
Get the string parameters from a given list.
protected array getNumericParameters(array $parameters)
Get the numeric parameters from a given list.
protected string getRouteDomain(Route $route, array $parameters)
Get the formatted domain for a given route.
protected string formatDomain(Route $route, array $parameters)
Format the domain and port for the route and request.
protected string getDomainAndScheme(Route $route)
Get the domain and scheme for the route.
protected string addPortToDomain(string $domain)
Add the port to the domain if necessary.
protected string getRouteRoot(Route $route, string $domain)
Get the root of the route URL.
protected string getRouteScheme(Route $route)
Get the scheme for the given route.
string action(string $action, mixed $parameters = [], bool $absolute = true)
Get the URL to a controller action.
protected string getRootUrl(string $scheme, string $root = null)
Get the base URL for the request.
void forceRootUrl(string $root)
Set the forced root URL.
bool isValidUrl(string $path)
Determine if the given path is a valid URL.
protected string trimUrl(string $root, string $path, string $tail = '')
Format the given URL segments into a single URL.
Request getRequest()
Get the request instance.
void setRequest(Request $request)
Set the current request instance.
$this setRoutes(RouteCollection $routes)
Set the route collection.
protected string|null getPreviousUrlFromSession()
Get the previous URL from the session if possible.
protected Store|null getSession()
Get the session implementation from the resolver.
$this setSessionResolver(callable $sessionResolver)
Set the session resolver for the generator.
$this setRootControllerNamespace(string $rootNamespace)
Set the root controller namespace.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.1/Illuminate/Routing/UrlGenerator.html