PHP Class Neos\Flow\Mvc\Routing\UriBuilder

Mostra file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$addQueryString boolean
$arguments array
$argumentsToBeExcludedFromQueryString array
$createAbsoluteUri boolean
$createRelativePaths boolean
$environment Neos\Flow\Utility\Environment
$format string
$lastArguments array Arguments which have been used for building the last URI
$request Neos\Flow\Mvc\ActionRequest
$router Neos\Flow\Mvc\Routing\RouterInterface
$section string

Public Methods

Method Description
build ( array $arguments = [] ) : string Builds the URI
getAddQueryString ( ) : boolean
getArguments ( ) : array
getArgumentsToBeExcludedFromQueryString ( ) : array
getCreateAbsoluteUri ( ) : boolean
getCreateRelativePaths ( ) : boolean
getFormat ( ) : string
getLastArguments ( ) : array Returns the arguments being used for the last URI being built.
getRequest ( ) : ActionRequest Gets the current request
getSection ( ) : string
reset ( ) : UriBuilder Resets all UriBuilder options to their default value.
setAddQueryString ( boolean $addQueryString ) : UriBuilder If set, the current query parameters will be merged with $this->arguments. Defaults to FALSE.
setArguments ( array $arguments ) : UriBuilder Additional query parameters.
setArgumentsToBeExcludedFromQueryString ( array $argumentsToBeExcludedFromQueryString ) : UriBuilder A list of arguments to be excluded from the query parameters Only active if addQueryString is set
setCreateAbsoluteUri ( boolean $createAbsoluteUri ) : UriBuilder If set, the URI is prepended with the current base URI. Defaults to FALSE.
setCreateRelativePaths ( boolean $createRelativePaths ) : UriBuilder By default relative URIs are prefixed with the current script request path creating absolute paths starting with a slash If this is set to FALSE, relative paths are created as it used to be the default behavior before Flow 2.0.
setFormat ( string $format ) : UriBuilder Specifies the format of the target (e.g. "html" or "xml")
setRequest ( ActionRequest $request ) : void Sets the current request and resets the UriBuilder
setSection ( string $section ) : UriBuilder If specified, adds a given HTML anchor to the URI (#.
uriFor ( string $actionName, array $controllerArguments = [], string $controllerName = null, string $packageKey = null, string $subPackageKey = null ) : string Creates an URI used for linking to an Controller action.

Protected Methods

Method Description
addNamespaceToArguments ( array $arguments, Neos\Flow\Mvc\RequestInterface $currentRequest ) : array Adds the argument namespace of the current request to the specified arguments.
getRequestNamespacePath ( ActionRequest $request ) : string Get the path of the argument namespaces of all parent requests.
mergeArgumentsWithRequestArguments ( array $arguments ) : array Merges specified arguments with arguments from request.

Method Details

addNamespaceToArguments() protected method

This happens recursively iterating through the nested requests in case of a subrequest. For example if this is executed inside a widget sub request in a plugin sub request, the result would be: array( 'pluginRequestNamespace' => array( 'widgetRequestNamespace => $arguments ) )
protected addNamespaceToArguments ( array $arguments, Neos\Flow\Mvc\RequestInterface $currentRequest ) : array
$arguments array arguments
$currentRequest Neos\Flow\Mvc\RequestInterface
return array arguments with namespace

build() public method

Builds the URI
public build ( array $arguments = [] ) : string
$arguments array optional URI arguments. Will be merged with $this->arguments with precedence to $arguments
return string The URI

getAddQueryString() public method

public getAddQueryString ( ) : boolean
return boolean

getArguments() public method

public getArguments ( ) : array
return array

getArgumentsToBeExcludedFromQueryString() public method

getCreateAbsoluteUri() public method

public getCreateAbsoluteUri ( ) : boolean
return boolean

getCreateRelativePaths() public method

public getCreateRelativePaths ( ) : boolean
return boolean

getFormat() public method

public getFormat ( ) : string
return string

getLastArguments() public method

This is only set after build() / uriFor() has been called.
public getLastArguments ( ) : array
return array The last arguments

getRequest() public method

Gets the current request
public getRequest ( ) : ActionRequest
return Neos\Flow\Mvc\ActionRequest

getRequestNamespacePath() protected method

Example: mainrequest.subrequest.subsubrequest
protected getRequestNamespacePath ( ActionRequest $request ) : string
$request Neos\Flow\Mvc\ActionRequest
return string

getSection() public method

public getSection ( ) : string
return string

mergeArgumentsWithRequestArguments() protected method

If $this->request is no sub request, request arguments will only be merged if $this->addQueryString is set. Otherwise all request arguments except for the ones prefixed with the current request argument namespace will be merged. Additionally special arguments (PackageKey, SubpackageKey, ControllerName & Action) are merged. The argument provided through the $arguments parameter always overrule the request arguments. The request hierarchy is structured as follows: root (HTTP) > main (Action) > sub (Action) > sub sub (Action)
protected mergeArgumentsWithRequestArguments ( array $arguments ) : array
$arguments array
return array

reset() public method

Note: This won't reset the Request that is attached to this UriBuilder (@see setRequest())
public reset ( ) : UriBuilder
return UriBuilder the current UriBuilder to allow method chaining

setAddQueryString() public method

If set, the current query parameters will be merged with $this->arguments. Defaults to FALSE.
public setAddQueryString ( boolean $addQueryString ) : UriBuilder
$addQueryString boolean
return UriBuilder the current UriBuilder to allow method chaining

setArguments() public method

If you want to "prefix" arguments, you can pass in multidimensional arrays: array('prefix1' => array('foo' => 'bar')) gets "&prefix1[foo]=bar"
public setArguments ( array $arguments ) : UriBuilder
$arguments array
return UriBuilder the current UriBuilder to allow method chaining

setArgumentsToBeExcludedFromQueryString() public method

A list of arguments to be excluded from the query parameters Only active if addQueryString is set
public setArgumentsToBeExcludedFromQueryString ( array $argumentsToBeExcludedFromQueryString ) : UriBuilder
$argumentsToBeExcludedFromQueryString array
return UriBuilder the current UriBuilder to allow method chaining

setCreateAbsoluteUri() public method

If set, the URI is prepended with the current base URI. Defaults to FALSE.
public setCreateAbsoluteUri ( boolean $createAbsoluteUri ) : UriBuilder
$createAbsoluteUri boolean
return UriBuilder the current UriBuilder to allow method chaining

setCreateRelativePaths() public method

By default relative URIs are prefixed with the current script request path creating absolute paths starting with a slash If this is set to FALSE, relative paths are created as it used to be the default behavior before Flow 2.0.
public setCreateRelativePaths ( boolean $createRelativePaths ) : UriBuilder
$createRelativePaths boolean
return UriBuilder the current UriBuilder to allow method chaining

setFormat() public method

Specifies the format of the target (e.g. "html" or "xml")
public setFormat ( string $format ) : UriBuilder
$format string (e.g. "html" or "xml"), will be transformed to lowercase!
return UriBuilder the current UriBuilder to allow method chaining

setRequest() public method

Sets the current request and resets the UriBuilder
See also: reset()
public setRequest ( ActionRequest $request ) : void
$request Neos\Flow\Mvc\ActionRequest
return void

setSection() public method

..)
public setSection ( string $section ) : UriBuilder
$section string
return UriBuilder the current UriBuilder to allow method chaining

uriFor() public method

Creates an URI used for linking to an Controller action.
See also: build()
public uriFor ( string $actionName, array $controllerArguments = [], string $controllerName = null, string $packageKey = null, string $subPackageKey = null ) : string
$actionName string Name of the action to be called
$controllerArguments array Additional query parameters. Will be merged with $this->arguments.
$controllerName string Name of the target controller. If not set, current ControllerName is used.
$packageKey string Name of the target package. If not set, current Package is used.
$subPackageKey string Name of the target SubPackage. If not set, current SubPackage is used.
return string the rendered URI

Property Details

$addQueryString protected_oe property

protected bool $addQueryString
return boolean

$arguments protected_oe property

protected array $arguments
return array

$argumentsToBeExcludedFromQueryString protected_oe property

protected array $argumentsToBeExcludedFromQueryString
return array

$createAbsoluteUri protected_oe property

protected bool $createAbsoluteUri
return boolean

$createRelativePaths protected_oe property

protected bool $createRelativePaths
return boolean

$environment protected_oe property

protected Environment,Neos\Flow\Utility $environment
return Neos\Flow\Utility\Environment

$format protected_oe property

protected string $format
return string

$lastArguments protected_oe property

Arguments which have been used for building the last URI
protected array $lastArguments
return array

$request protected_oe property

protected ActionRequest,Neos\Flow\Mvc $request
return Neos\Flow\Mvc\ActionRequest

$router protected_oe property

protected RouterInterface,Neos\Flow\Mvc\Routing $router
return Neos\Flow\Mvc\Routing\RouterInterface

$section protected_oe property

protected string $section
return string