UriBuilder

class \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder

An URI Builder

Table of Contents

Properties

$absoluteUriScheme  : string|null
$addQueryString  : bool
$argumentPrefix  : string|null
$arguments  : array
$argumentsToBeExcludedFromQueryString  : array
$configurationManager  : ConfigurationManagerInterface
$contentObject  : ContentObjectRenderer
An instance of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
$createAbsoluteUri  : bool
$extensionService  : ExtensionService
$format  : string
$language  : string|null
$lastArguments  : array
Arguments which have been used for building the last URI
$linkAccessRestrictedPages  : bool
$noCache  : bool
$request  : Request|null
$section  : string
$targetPageType  : int
$targetPageUid  : int|null

Methods

build()  : string
Builds the URI Depending on the current context this calls buildBackendUri() or buildFrontendUri()
buildBackendUri()  : string
Builds the URI, backend flavour The resulting URI is relative and starts with "index.php".
buildFrontendUri()  : string
Builds the URI, frontend flavour
convertTransientObjectToArray()  : array
Converts a given object recursively into an array.
getAbsoluteUriScheme()  : string|null
getAddQueryString()  : bool
getArgumentPrefix()  : string|null
getArguments()  : array
getArgumentsToBeExcludedFromQueryString()  : array
getCreateAbsoluteUri()  : bool
getFormat()  : string
getLanguage()  : string|null
getLastArguments()  : array
Returns the arguments being used for the last URI being built.
getLinkAccessRestrictedPages()  : bool
getNoCache()  : bool
getRequest()  : Request|null
getSection()  : string
getTargetPageType()  : int
getTargetPageUid()  : int|null
returns $this->targetPageUid.
initializeObject()  : void
Life-cycle method that is called by the DI container as soon as this object is completely built
injectConfigurationManager()  : void
injectExtensionService()  : void
reset()  : static
Resets all UriBuilder options to their default value
setAbsoluteUriScheme()  : static
Sets the scheme that should be used for absolute URIs in FE mode
setAddQueryString()  : static
If set, the current query parameters will be merged with $this->arguments. Defaults to FALSE.
setAddQueryStringMethod()  : static
Sets the method to get the addQueryString parameters. Defaults to an empty string which results in using GeneralUtility::_GET(). Possible values are
setArgumentPrefix()  : static
Specifies the prefix to be used for all arguments.
setArguments()  : static
Additional query parameters.
setArgumentsToBeExcludedFromQueryString()  : static
A list of arguments to be excluded from the query parameters Only active if addQueryString is set
setCreateAbsoluteUri()  : static
If set, the URI is prepended with the current base URI. Defaults to FALSE.
setFormat()  : static
Specifies the format of the target (e.g. "html" or "xml")
setLanguage()  : UriBuilder
Enforces a URI / link to a page to a specific language (or use "current")
setLinkAccessRestrictedPages()  : static
If set, URIs for pages without access permissions will be created
setNoCache()  : static
by default FALSE; if TRUE, &no_cache=1 will be appended to the URI
setRequest()  : static
Sets the current request
setSection()  : static
If specified, adds a given HTML anchor to the URI (#...)
setTargetPageType()  : static
Sets the page type of the target URI. Defaults to 0
setTargetPageUid()  : static
Uid of the target page
uriFor()  : string
Creates an URI used for linking to an Extbase action.
buildTypolinkConfiguration()  : array
Builds a TypoLink configuration array from the current settings
convertDomainObjectsToIdentityArrays()  : array
Recursively iterates through the specified arguments and turns instances of type \TYPO3\CMS\Extbase\DomainObject\AbstractEntity into an arrays containing the uid of the domain object.
convertIteratorToArray()  : array
removeDefaultControllerAndAction()  : array
This removes controller and/or action arguments from given controllerArguments if they are equal to the default controller/action of the target plugin.

Properties

$absoluteUriScheme

protected string|null $absoluteUriScheme

$addQueryString

protected bool $addQueryString = false

$argumentPrefix

protected string|null $argumentPrefix

$argumentsToBeExcludedFromQueryString

protected array $argumentsToBeExcludedFromQueryString = []

$createAbsoluteUri

protected bool $createAbsoluteUri = false

$lastArguments

Arguments which have been used for building the last URI

protected array $lastArguments = []

$linkAccessRestrictedPages

protected bool $linkAccessRestrictedPages = false

$targetPageType

protected int $targetPageType = 0

$targetPageUid

protected int|null $targetPageUid

Methods

build()

Builds the URI Depending on the current context this calls buildBackendUri() or buildFrontendUri()

public build() : string

Tags

see
buildBackendUri()
see
buildFrontendUri()

Return values

string —

The URI

buildBackendUri()

Builds the URI, backend flavour The resulting URI is relative and starts with "index.php".

public buildBackendUri() : string

The settings pageUid, pageType, noCache & linkAccessRestrictedPages will be ignored in the backend.

Tags

see
ContentObjectRenderer::getQueryArguments

Return values

string —

The URI

buildFrontendUri()

Builds the URI, frontend flavour

public buildFrontendUri() : string

Tags

see
buildTypolinkConfiguration()

Return values

string —

The URI

convertTransientObjectToArray()

Converts a given object recursively into an array.

public convertTransientObjectToArray(AbstractDomainObject $object) : array

Parameters

$object : AbstractDomainObject

Tags

todo

Refactor this into convertDomainObjectsToIdentityArrays()

Return values

array

getAbsoluteUriScheme()

public getAbsoluteUriScheme() : string|null

Return values

string|null

getAddQueryString()

public getAddQueryString() : bool

Return values

bool

getArgumentPrefix()

public getArgumentPrefix() : string|null

Return values

string|null

getArguments()

public getArguments() : array

Return values

array

getArgumentsToBeExcludedFromQueryString()

public getArgumentsToBeExcludedFromQueryString() : array

Return values

array

getCreateAbsoluteUri()

public getCreateAbsoluteUri() : bool

Return values

bool

getFormat()

public getFormat() : string

Return values

string

getLanguage()

public getLanguage() : string|null

Return values

string|null

getLastArguments()

Returns the arguments being used for the last URI being built.

public getLastArguments() : array

This is only set after build() / uriFor() has been called.

Return values

array —

The last arguments

getLinkAccessRestrictedPages()

public getLinkAccessRestrictedPages() : bool

Return values

bool

getNoCache()

public getNoCache() : bool

Return values

bool

getRequest()

public getRequest() : Request|null

Return values

Request|null

getSection()

public getSection() : string

Return values

string

getTargetPageType()

public getTargetPageType() : int

Return values

int

getTargetPageUid()

returns $this->targetPageUid.

public getTargetPageUid() : int|null

Return values

int|null

initializeObject()

Life-cycle method that is called by the DI container as soon as this object is completely built

public initializeObject() : void

injectExtensionService()

public injectExtensionService(ExtensionService $extensionService) : void

Parameters

$extensionService : ExtensionService

reset()

Resets all UriBuilder options to their default value

public reset() : static

Return values

static —

the current UriBuilder to allow method chaining

setAbsoluteUriScheme()

Sets the scheme that should be used for absolute URIs in FE mode

public setAbsoluteUriScheme(string $absoluteUriScheme) : static

Parameters

$absoluteUriScheme : string

the scheme to be used for absolute URIs

Return values

static —

the current UriBuilder to allow method chaining

setAddQueryStringMethod()

Sets the method to get the addQueryString parameters. Defaults to an empty string which results in using GeneralUtility::_GET(). Possible values are

public setAddQueryStringMethod(string $addQueryStringMethod) : static
  • '' -> uses GeneralUtility::_GET()
  • '0' -> uses GeneralUtility::_GET()
  • 'GET' -> uses GeneralUtility::_GET()
  • '' -> uses parse_str(GeneralUtility::getIndpEnv('QUERY_STRING')) ( refers to literally everything else than previously mentioned values)

Parameters

$addQueryStringMethod : string

Tags

see
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Typolink.html#addquerystring

Return values

static —

the current UriBuilder to allow method chaining

setArgumentPrefix()

Specifies the prefix to be used for all arguments.

public setArgumentPrefix(string $argumentPrefix) : static

Parameters

$argumentPrefix : string

Return values

static —

the current UriBuilder to allow method chaining

setArguments()

Additional query parameters.

public setArguments(array $arguments) : static

If you want to "prefix" arguments, you can pass in multidimensional arrays: array('prefix1' => array('foo' => 'bar')) gets "&prefix1[foo]=bar"

Parameters

$arguments : array

Return values

static —

the current UriBuilder to allow method chaining

setArgumentsToBeExcludedFromQueryString()

A list of arguments to be excluded from the query parameters Only active if addQueryString is set

public setArgumentsToBeExcludedFromQueryString(array $argumentsToBeExcludedFromQueryString) : static

Parameters

$argumentsToBeExcludedFromQueryString : array

Tags

see
https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Functions/Typolink.html#addquerystring
see
setAddQueryString()

Return values

static —

the current UriBuilder to allow method chaining

setCreateAbsoluteUri()

If set, the URI is prepended with the current base URI. Defaults to FALSE.

public setCreateAbsoluteUri(bool $createAbsoluteUri) : static

Parameters

$createAbsoluteUri : bool

Return values

static —

the current UriBuilder to allow method chaining

setFormat()

Specifies the format of the target (e.g. "html" or "xml")

public setFormat(string $format) : static

Parameters

$format : string

Return values

static —

the current UriBuilder to allow method chaining

setLanguage()

Enforces a URI / link to a page to a specific language (or use "current")

public setLanguage(string|null $language) : UriBuilder

Parameters

$language : string|null

Return values

UriBuilder

setLinkAccessRestrictedPages()

If set, URIs for pages without access permissions will be created

public setLinkAccessRestrictedPages(bool $linkAccessRestrictedPages) : static

Parameters

$linkAccessRestrictedPages : bool

Return values

static —

the current UriBuilder to allow method chaining

setNoCache()

by default FALSE; if TRUE, &no_cache=1 will be appended to the URI

public setNoCache(bool $noCache) : static

Parameters

$noCache : bool

Return values

static —

the current UriBuilder to allow method chaining

setRequest()

Sets the current request

public setRequest(Request $request) : static

Parameters

$request : Request

Return values

static —

the current UriBuilder to allow method chaining

setSection()

If specified, adds a given HTML anchor to the URI (#...)

public setSection(string $section) : static

Parameters

$section : string

Return values

static —

the current UriBuilder to allow method chaining

setTargetPageType()

Sets the page type of the target URI. Defaults to 0

public setTargetPageType(int $targetPageType) : static

Parameters

$targetPageType : int

Return values

static —

the current UriBuilder to allow method chaining

setTargetPageUid()

Uid of the target page

public setTargetPageUid(int $targetPageUid) : static

Parameters

$targetPageUid : int

Return values

static —

the current UriBuilder to allow method chaining

uriFor()

Creates an URI used for linking to an Extbase action.

public uriFor([string|null $actionName = null ][, array|null $controllerArguments = null ][, string|null $controllerName = null ][, string|null $extensionName = null ][, string|null $pluginName = null ]) : string

Works in Frontend and Backend mode of TYPO3.

Parameters

$actionName : string|null = null

Name of the action to be called

$controllerArguments : array|null = null

Additional query parameters. Will be "namespaced" and merged with $this->arguments.

$controllerName : string|null = null

Name of the target controller. If not set, current ControllerName is used.

$extensionName : string|null = null

Name of the target extension, without underscores. If not set, current ExtensionName is used.

$pluginName : string|null = null

Name of the target plugin. If not set, current PluginName is used.

Tags

see
build()

Return values

string —

the rendered URI

convertDomainObjectsToIdentityArrays()

Recursively iterates through the specified arguments and turns instances of type \TYPO3\CMS\Extbase\DomainObject\AbstractEntity into an arrays containing the uid of the domain object.

protected convertDomainObjectsToIdentityArrays(array $arguments) : array

Parameters

$arguments : array

The arguments to be iterated

Tags

throws
InvalidArgumentValueException

Return values

array —

The modified arguments array

convertIteratorToArray()

protected convertIteratorToArray(Iterator $iterator) : array

Parameters

$iterator : Iterator

Return values

array

removeDefaultControllerAndAction()

This removes controller and/or action arguments from given controllerArguments if they are equal to the default controller/action of the target plugin.

protected removeDefaultControllerAndAction(array $controllerArguments, string $extensionName, string $pluginName) : array

Note: This is only active in FE mode and if feature "skipDefaultArguments" is enabled

Parameters

$controllerArguments : array

the current controller arguments to be modified

$extensionName : string

target extension name

$pluginName : string

target plugin name

Tags

see
ConfigurationManagerInterface::isFeatureEnabled()

Return values

array
On this page