TYPO3 CMS  TYPO3_8-7
TYPO3\CMS\Backend\Routing\UriBuilder Class Reference

Public Member Functions

 buildUriFromRoute ($name, $parameters=[], $referenceType=self::ABSOLUTE_PATH)
 
 buildUriFromModule ($moduleName, $parameters=[], $referenceType=self::ABSOLUTE_PATH)
 
 buildUriFromAjaxId ($ajaxIdentifier, $parameters=[], $referenceType=self::ABSOLUTE_PATH)
 

Public Attributes

const ABSOLUTE_URL = 'url'
 
const ABSOLUTE_PATH = 'absolute'
 

Protected Member Functions

 loadBackendRoutes ()
 
 buildUri ($parameters, $referenceType)
 

Protected Attributes

 $routes
 

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 31 of file UriBuilder.php.

Member Function Documentation

◆ buildUri()

TYPO3\CMS\Backend\Routing\UriBuilder::buildUri (   $parameters,
  $referenceType 
)
protected

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

Parameters
array$parametersAn array of GET parameters
string$referenceTypeThe type of reference to be generated (one of the constants)
Returns
Uri

Definition at line 161 of file UriBuilder.php.

References TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Core\Utility\GeneralUtility\implodeArrayForUrl(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromAjaxId(), TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromModule(), and TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoute().

◆ buildUriFromAjaxId()

TYPO3\CMS\Backend\Routing\UriBuilder::buildUriFromAjaxId (   $ajaxIdentifier,
  $parameters = [],
  $referenceType = self::ABSOLUTE_PATH 
)

Returns the Ajax URL for a given AjaxID including a CSRF token.

This method is only called by the core and must not be used by extensions. Ajax URLs of all registered backend Ajax handlers are automatically published to JavaScript inline settings: TYPO3.settings.ajaxUrls['ajaxId']

Parameters
string$ajaxIdentifierthe ajaxID (used as GET parameter)
array$parametersAn array of parameters
string$referenceTypeThe type of reference to be generated (one of the constants)
Returns
Uri The generated Uri
Deprecated:
since TYPO3 v8, will be removed in TYPO3 v9, use the buildUriFromRoute() method

Definition at line 141 of file UriBuilder.php.

References $GLOBALS, TYPO3\CMS\Backend\Routing\UriBuilder\buildUri(), TYPO3\CMS\Core\FormProtection\FormProtectionFactory\get(), and TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction().

◆ buildUriFromModule()

TYPO3\CMS\Backend\Routing\UriBuilder::buildUriFromModule (   $moduleName,
  $parameters = [],
  $referenceType = self::ABSOLUTE_PATH 
)

Generate a URI for a backend module, does not check if a module is available though

Parameters
string$moduleNameThe name of the module
array$parametersAn array of parameters
string$referenceTypeThe type of reference to be generated (one of the constants)
Returns
Uri The generated Uri

Definition at line 118 of file UriBuilder.php.

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

◆ buildUriFromRoute()

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$nameThe name of the route
array$parametersAn array of parameters
string$referenceTypeThe type of reference to be generated (one of the constants)
Returns
Uri The generated Uri
Exceptions
RouteNotFoundExceptionIf the named route doesn't exist

Definition at line 69 of file UriBuilder.php.

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

◆ loadBackendRoutes()

TYPO3\CMS\Backend\Routing\UriBuilder::loadBackendRoutes ( )
protected

Fetches the available routes from the Router to be used for generating routes

Definition at line 51 of file UriBuilder.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

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

Member Data Documentation

◆ $routes

TYPO3\CMS\Backend\Routing\UriBuilder::$routes
protected

Definition at line 46 of file UriBuilder.php.

◆ ABSOLUTE_PATH

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

Generates an absolute path

Definition at line 41 of file UriBuilder.php.

◆ ABSOLUTE_URL

const TYPO3\CMS\Backend\Routing\UriBuilder::ABSOLUTE_URL = 'url'

Generates an absolute URL

Definition at line 36 of file UriBuilder.php.