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
- $formProtectionFactory : FormProtectionFactory
- $generated : array<non-empty-string, UriInterface>
- $requestContext : RequestContext|null
- $requestContextFactory : RequestContextFactory
- $router : Router
Methods
- __construct() : mixed
- Loads the router to fetch the available routes from the Router to be used for generating routes
- buildUriFromRoute() : UriInterface
- Generates a URL or path for a specific route based on the given parameters.
- buildUriFromRoutePath() : UriInterface
- Generates a URL or path for a specific route based on the given route.
- buildUriWithRedirect() : UriInterface
- Creates a link to a page with a route targetted as a redirect, if a "deep link" is possible.
- setRequestContext() : void
- buildUri() : UriInterface
- 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
$formProtectionFactory read-only
protected
FormProtectionFactory
$formProtectionFactory
$generated
protected
array<non-empty-string, UriInterface>
$generated
= []
$requestContext
protected
RequestContext|null
$requestContext
= null
$requestContextFactory read-only
protected
RequestContextFactory
$requestContextFactory
$router read-only
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, FormProtectionFactory $formProtectionFactory, RequestContextFactory $requestContextFactory) : mixed
Parameters
- $router : Router
- $formProtectionFactory : FormProtectionFactory
- $requestContextFactory : RequestContextFactory
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 ]) : UriInterface
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
UriInterface —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 ]) : UriInterface
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
UriInterface —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 ]) : UriInterface
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
UriInterfacesetRequestContext()
public
setRequestContext(RequestContext $requestContext) : void
Parameters
- $requestContext : RequestContext
buildUri()
Internal method building a Uri object, merging the GET parameters array into a flat queryString
protected
buildUri(string $routeName, array<string|int, mixed> $parameters, string $referenceType) : UriInterface
Parameters
- $routeName : string
-
The route name in the collection
- $parameters : array<string|int, mixed>
-
An array of GET parameters
- $referenceType : string
-
The type of reference to be generated (one of the constants)