UriBuilder implements SingletonInterface
Main UrlGenerator for creating URLs for the Backend. Generates a URL based on an identifier defined by Configuration/Backend/Routes.php of an extension, and adds some more parameters to the URL.
Currently only available and useful when called from Router->generate() as the information about possible routes needs to be handed over.
Table of Contents
Interfaces
- SingletonInterface
- "empty" interface for singletons (marker interface pattern)
Constants
- ABSOLUTE_PATH = 'absolute'
- Generates an absolute path
- ABSOLUTE_URL = 'url'
- Generates an absolute URL
- SHAREABLE_URL = 'share'
- Generates an absolute url for URL sharing
Properties
- $generated : array<string|int, mixed>
- $router : Router
Methods
- __construct() : mixed
- Loads the router to fetch the available routes from the Router to be used for generating routes
- buildUriFromRoute() : Uri
- Generates a URL or path for a specific route based on the given parameters.
- buildUriFromRoutePath() : Uri
- Generates a URL or path for a specific route based on the given route.
- buildUriWithRedirect() : Uri
- Creates a link to a page with a route targetted as a redirect, if a "deep link" is possible.
- buildUri() : Uri
- Internal method building a Uri object, merging the GET parameters array into a flat queryString
Constants
ABSOLUTE_PATH
Generates an absolute path
public
mixed
ABSOLUTE_PATH
= 'absolute'
ABSOLUTE_URL
Generates an absolute URL
public
mixed
ABSOLUTE_URL
= 'url'
SHAREABLE_URL
Generates an absolute url for URL sharing
public
mixed
SHAREABLE_URL
= 'share'
Properties
$generated
protected
array<string|int, mixed>
$generated
= []
$router
protected
Router
$router
Methods
__construct()
Loads the router to fetch the available routes from the Router to be used for generating routes
public
__construct(Router $router) : mixed
Parameters
- $router : Router
buildUriFromRoute()
Generates a URL or path for a specific route based on the given parameters.
public
buildUriFromRoute(string $name[, array<string|int, mixed> $parameters = [] ][, string $referenceType = self::ABSOLUTE_PATH ]) : Uri
When the route is configured with "access=public" then the token generation is left out.
If there is no route with the given name, the generator throws the RouteNotFoundException.
Parameters
- $name : string
-
The name of the route
- $parameters : array<string|int, mixed> = []
-
An array of parameters
- $referenceType : string = self::ABSOLUTE_PATH
-
The type of reference to be generated (one of the constants)
Tags
Return values
Uri —The generated Uri
buildUriFromRoutePath()
Generates a URL or path for a specific route based on the given route.
public
buildUriFromRoutePath(string $pathInfo[, array<string|int, mixed> $parameters = [] ][, string $referenceType = self::ABSOLUTE_PATH ]) : Uri
Currently used to link to the current script, it is encouraged to use "buildUriFromRoute" if possible.
If there is no route with the given name, the generator throws the RouteNotFoundException.
Parameters
- $pathInfo : string
-
The path to the route
- $parameters : array<string|int, mixed> = []
-
An array of parameters
- $referenceType : string = self::ABSOLUTE_PATH
-
The type of reference to be generated (one of the constants)
Tags
Return values
Uri —The generated Uri
buildUriWithRedirect()
Creates a link to a page with a route targetted as a redirect, if a "deep link" is possible.
public
buildUriWithRedirect(string $name[, array<string|int, mixed> $parameters = [] ][, RouteRedirect|null $redirect = null ][, string $referenceType = self::ABSOLUTE_PATH ]) : Uri
Currently works just fine for URLs built for "main" and "login" pages.
Parameters
- $name : string
- $parameters : array<string|int, mixed> = []
- $redirect : RouteRedirect|null = null
- $referenceType : string = self::ABSOLUTE_PATH
this is experimental API used for creating logins to redirect to a different route
Tags
Return values
UribuildUri()
Internal method building a Uri object, merging the GET parameters array into a flat queryString
protected
buildUri(string $route, array<string|int, mixed> $parameters, string $referenceType) : Uri
Parameters
- $route : string
-
The route path to prepend
- $parameters : array<string|int, mixed>
-
An array of GET parameters
- $referenceType : string
-
The type of reference to be generated (one of the constants)