‪TYPO3CMS  11.5
TYPO3\CMS\Backend\Routing\UriBuilder Class Reference
Inheritance diagram for TYPO3\CMS\Backend\Routing\UriBuilder:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (Router $router)
 
Uri buildUriFromRoutePath ($pathInfo, $parameters=[], $referenceType=self::ABSOLUTE_PATH)
 
Uri buildUriWithRedirect (string $name, array $parameters=[], RouteRedirect $redirect=null, string $referenceType=self::ABSOLUTE_PATH)
 
Uri buildUriFromRoute ($name, $parameters=[], $referenceType=self::ABSOLUTE_PATH)
 

Public Attributes

const ABSOLUTE_URL = 'url'
 
const ABSOLUTE_PATH = 'absolute'
 
const SHAREABLE_URL = 'share'
 

Protected Member Functions

Uri buildUri (string $route, array $parameters, string $referenceType)
 

Protected Attributes

Router $router
 
array $generated = array( )
 

Detailed Description

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.

Definition at line 39 of file UriBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Routing\UriBuilder::__construct ( Router  $router)

Loads the router to fetch the available routes from the Router to be used for generating routes

Parameters
Router$router

Definition at line 68 of file UriBuilder.php.

References TYPO3\CMS\Backend\Routing\UriBuilder\$router.

Member Function Documentation

◆ buildUri()

Uri TYPO3\CMS\Backend\Routing\UriBuilder::buildUri ( string  $route,
array  $parameters,
string  $referenceType 
)
protected

Internal method building a Uri object, merging the GET parameters array into a flat queryString

Parameters
string$route‪The route path to prepend
array$parameters‪An array of GET parameters
string$referenceType‪The type of reference to be generated (one of the constants)
Returns
‪Uri

Definition at line 170 of file UriBuilder.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString(), TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath(), and TYPO3\CMS\Core\Core\Environment\getBackendPath().

Referenced by TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoute().

◆ buildUriFromRoute()

Uri TYPO3\CMS\Backend\Routing\UriBuilder::buildUriFromRoute (   $name,
  $parameters = [],
  $referenceType = self::ABSOLUTE_PATH 
)

Generates a URL or path for a specific route based on the given parameters. 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
string$name‪The name of the route
array$parameters‪An array of parameters
string$referenceType‪The type of reference to be generated (one of the constants)
Returns
‪Uri The generated Uri
Exceptions
RouteNotFoundException‪If the named route doesn't exist

Definition at line 133 of file UriBuilder.php.

References TYPO3\CMS\Backend\Routing\UriBuilder\buildUri(), TYPO3\CMS\Core\FormProtection\AbstractFormProtection\generateToken(), and TYPO3\CMS\Core\FormProtection\FormProtectionFactory\get().

Referenced by TYPO3\CMS\Backend\Backend\ToolbarItems\ClearCacheToolbarItem\__construct(), TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoutePath(), and TYPO3\CMS\Backend\Routing\UriBuilder\buildUriWithRedirect().

◆ buildUriFromRoutePath()

Uri TYPO3\CMS\Backend\Routing\UriBuilder::buildUriFromRoutePath (   $pathInfo,
  $parameters = [],
  $referenceType = self::ABSOLUTE_PATH 
)

Generates a URL or path for a specific route based on the given route. 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
string$pathInfo‪The path to the route
array$parameters‪An array of parameters
string$referenceType‪The type of reference to be generated (one of the constants)
Returns
‪Uri The generated Uri
Exceptions
RouteNotFoundException‪If the named route doesn't exist

Definition at line 85 of file UriBuilder.php.

References TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoute().

◆ buildUriWithRedirect()

Uri TYPO3\CMS\Backend\Routing\UriBuilder::buildUriWithRedirect ( string  $name,
array  $parameters = [],
RouteRedirect  $redirect = null,
string  $referenceType = self::ABSOLUTE_PATH 
)

Creates a link to a page with a route targetted as a redirect, if a "deep link" is possible. Currently works just fine for URLs built for "main" and "login" pages.

Parameters
string$name
array$parameters
RouteRedirect | null$redirect
string$referenceType
Returns
‪Uri
Exceptions
RouteNotFoundException

this is experimental API used for creating logins to redirect to a different route

Definition at line 103 of file UriBuilder.php.

References TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoute().

Member Data Documentation

◆ $generated

array TYPO3\CMS\Backend\Routing\UriBuilder::$generated = array( )
protected

Definition at line 62 of file UriBuilder.php.

◆ $router

Router TYPO3\CMS\Backend\Routing\UriBuilder::$router
protected

Definition at line 58 of file UriBuilder.php.

Referenced by TYPO3\CMS\Backend\Routing\UriBuilder\__construct().

◆ ABSOLUTE_PATH

const TYPO3\CMS\Backend\Routing\UriBuilder::ABSOLUTE_PATH = 'absolute'

◆ ABSOLUTE_URL

◆ SHAREABLE_URL

const TYPO3\CMS\Backend\Routing\UriBuilder::SHAREABLE_URL = 'share'

Generates an absolute url for URL sharing

Definition at line 54 of file UriBuilder.php.

Referenced by TYPO3\CMS\Backend\Template\Components\Buttons\Action\ShortcutButton\createShortcutMarkup().