UriBuilder
An URI Builder
Table of Contents
Properties
- $absoluteUriScheme : string|null
- $addQueryString : bool
- $argumentPrefix : string|null
- $arguments : array<string|int, mixed>
- $argumentsToBeExcludedFromQueryString : array<string|int, mixed>
- $configurationManager : ConfigurationManagerInterface
- $contentObject : ContentObjectRenderer
- An instance of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
- $createAbsoluteUri : bool
- $extensionService : ExtensionService
- $format : string
- $language : string|null
- $lastArguments : array<string|int, mixed>
- 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<string|int, mixed>
- Converts a given object recursively into an array.
- getAbsoluteUriScheme() : string|null
- getAddQueryString() : bool
- getArgumentPrefix() : string|null
- getArguments() : array<string|int, mixed>
- getArgumentsToBeExcludedFromQueryString() : array<string|int, mixed>
- getCreateAbsoluteUri() : bool
- getFormat() : string
- getLanguage() : string|null
- getLastArguments() : array<string|int, mixed>
- 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<string|int, mixed>
- Builds a TypoLink configuration array from the current settings
- convertDomainObjectsToIdentityArrays() : array<string|int, mixed>
- 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<string|int, mixed>
- removeDefaultControllerAndAction() : array<string|int, mixed>
- 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
$arguments
protected
array<string|int, mixed>
$arguments
= []
$argumentsToBeExcludedFromQueryString
protected
array<string|int, mixed>
$argumentsToBeExcludedFromQueryString
= []
$configurationManager
protected
ConfigurationManagerInterface
$configurationManager
$contentObject
An instance of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
protected
ContentObjectRenderer
$contentObject
$createAbsoluteUri
protected
bool
$createAbsoluteUri
= false
$extensionService
protected
ExtensionService
$extensionService
$format
protected
string
$format
= ''
$language
protected
string|null
$language
$lastArguments
Arguments which have been used for building the last URI
protected
array<string|int, mixed>
$lastArguments
= []
$linkAccessRestrictedPages
protected
bool
$linkAccessRestrictedPages
= false
$noCache
protected
bool
$noCache
= false
$request
protected
Request|null
$request
$section
protected
string
$section
= ''
$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
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.
only to be used within Extbase, not part of TYPO3 Core API.
Tags
Return values
string —The URI
buildFrontendUri()
Builds the URI, frontend flavour
public
buildFrontendUri() : string
only to be used within Extbase, not part of TYPO3 Core API.
Tags
Return values
string —The URI
convertTransientObjectToArray()
Converts a given object recursively into an array.
public
convertTransientObjectToArray(AbstractDomainObject $object) : array<string|int, mixed>
Parameters
- $object : AbstractDomainObject
only to be used within Extbase, not part of TYPO3 Core API.
Tags
Return values
array<string|int, mixed>getAbsoluteUriScheme()
public
getAbsoluteUriScheme() : string|null
only to be used within Extbase, not part of TYPO3 Core API.
Return values
string|nullgetAddQueryString()
public
getAddQueryString() : bool
Return values
boolgetArgumentPrefix()
public
getArgumentPrefix() : string|null
only to be used within Extbase, not part of TYPO3 Core API.
Return values
string|nullgetArguments()
public
getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getArgumentsToBeExcludedFromQueryString()
public
getArgumentsToBeExcludedFromQueryString() : array<string|int, mixed>
Return values
array<string|int, mixed>getCreateAbsoluteUri()
public
getCreateAbsoluteUri() : bool
Return values
boolgetFormat()
public
getFormat() : string
Return values
stringgetLanguage()
public
getLanguage() : string|null
Return values
string|nullgetLastArguments()
Returns the arguments being used for the last URI being built.
public
getLastArguments() : array<string|int, mixed>
This is only set after build() / uriFor() has been called.
only to be used within Extbase, not part of TYPO3 Core API.
Return values
array<string|int, mixed> —The last arguments
getLinkAccessRestrictedPages()
public
getLinkAccessRestrictedPages() : bool
Return values
boolgetNoCache()
public
getNoCache() : bool
Return values
boolgetRequest()
public
getRequest() : Request|null
only to be used within Extbase, not part of TYPO3 Core API.
Return values
Request|nullgetSection()
public
getSection() : string
Return values
stringgetTargetPageType()
public
getTargetPageType() : int
only to be used within Extbase, not part of TYPO3 Core API.
Return values
intgetTargetPageUid()
returns $this->targetPageUid.
public
getTargetPageUid() : int|null
Return values
int|nullinitializeObject()
Life-cycle method that is called by the DI container as soon as this object is completely built
public
initializeObject() : void
only to be used within Extbase, not part of TYPO3 Core API.
injectConfigurationManager()
public
injectConfigurationManager(ConfigurationManagerInterface $configurationManager) : void
Parameters
- $configurationManager : ConfigurationManagerInterface
only to be used within Extbase, not part of TYPO3 Core API.
injectExtensionService()
public
injectExtensionService(ExtensionService $extensionService) : void
Parameters
- $extensionService : ExtensionService
only to be used within Extbase, not part of TYPO3 Core API.
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
setAddQueryString()
If set, the current query parameters will be merged with $this->arguments. Defaults to FALSE.
public
setAddQueryString(bool $addQueryString) : static
Parameters
- $addQueryString : bool
Tags
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
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<string|int, mixed> $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<string|int, mixed>
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<string|int, mixed> $argumentsToBeExcludedFromQueryString) : static
Parameters
- $argumentsToBeExcludedFromQueryString : array<string|int, mixed>
Tags
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
UriBuildersetLinkAccessRestrictedPages()
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
only to be used within Extbase, not part of TYPO3 Core API.
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<string|int, mixed>|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<string|int, mixed>|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
Return values
string —the rendered URI
buildTypolinkConfiguration()
Builds a TypoLink configuration array from the current settings
protected
buildTypolinkConfiguration() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —typolink configuration array
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<string|int, mixed> $arguments) : array<string|int, mixed>
Parameters
- $arguments : array<string|int, mixed>
-
The arguments to be iterated
Tags
Return values
array<string|int, mixed> —The modified arguments array
convertIteratorToArray()
protected
convertIteratorToArray(Iterator $iterator) : array<string|int, mixed>
Parameters
- $iterator : Iterator
Return values
array<string|int, mixed>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<string|int, mixed> $controllerArguments, string $extensionName, string $pluginName) : array<string|int, mixed>
Note: This is only active in FE mode and if feature "skipDefaultArguments" is enabled
Parameters
- $controllerArguments : array<string|int, mixed>
-
the current controller arguments to be modified
- $extensionName : string
-
target extension name
- $pluginName : string
-
target plugin name