UriBuilder
class UriBuilder (View source)
An URI Builder
Properties
| protected RouterInterface | $router | ||
| protected Environment | $environment | ||
| protected BaseUriProvider | $baseUriProvider | ||
| protected ActionRequest | $request | ||
| protected array | $arguments | ||
| protected array | $lastArguments | Arguments which have been used for building the last URI  | 
                |
| protected string | $section | ||
| protected bool | $createAbsoluteUri | ||
| protected bool | $addQueryString | ||
| protected array | $argumentsToBeExcludedFromQueryString | ||
| protected string | $format | 
Methods
Gets the current request
Additional query parameters.
No description
If specified, adds a given HTML anchor to the URI (#...)
No description
Specifies the format of the target (e.g. "html" or "xml")
No description
If set, the URI is prepended with the current base URI. Defaults to false.
No description
If set, the current query parameters will be merged with $this->arguments. Defaults to false.
No description
A list of arguments to be excluded from the query parameters Only active if addQueryString is set
No description
Returns the arguments being used for the last URI being built.
Resets all UriBuilder options to their default value.
Creates an URI used for linking to an Controller action.
Adds the argument namespace of the current request to the specified arguments.
Builds the URI
Merges specified arguments with arguments from request.
Get the path of the argument namespaces of all parent requests.
Details
        
                            void
    setRequest(ActionRequest $request)
        
    
    Sets the current request and resets the UriBuilder
        
                            ActionRequest
    getRequest()
        
    
    Gets the current request
        
                            UriBuilder
    setArguments(array $arguments)
        
    
    Additional query parameters.
If you want to "prefix" arguments, you can pass in multidimensional arrays: array('prefix1' => array('foo' => 'bar')) gets "&prefix1[foo]=bar"
        
                            array
    getArguments()
        
    
    No description
        
                            UriBuilder
    setSection(string $section)
        
    
    If specified, adds a given HTML anchor to the URI (#...)
        
                            string
    getSection()
        
    
    No description
        
                            UriBuilder
    setFormat(string $format)
        
    
    Specifies the format of the target (e.g. "html" or "xml")
        
                            string
    getFormat()
        
    
    No description
        
                            UriBuilder
    setCreateAbsoluteUri(bool $createAbsoluteUri)
        
    
    If set, the URI is prepended with the current base URI. Defaults to false.
        
                            bool
    getCreateAbsoluteUri()
        
    
    No description
        
                            UriBuilder
    setAddQueryString(bool $addQueryString)
        
    
    If set, the current query parameters will be merged with $this->arguments. Defaults to false.
        
                            bool
    getAddQueryString()
        
    
    No description
        
                            UriBuilder
    setArgumentsToBeExcludedFromQueryString(array $argumentsToBeExcludedFromQueryString)
        
    
    A list of arguments to be excluded from the query parameters Only active if addQueryString is set
        
                            array
    getArgumentsToBeExcludedFromQueryString()
        
    
    No description
        
                            array
    getLastArguments()
        
    
    Returns the arguments being used for the last URI being built.
This is only set after build() / uriFor() has been called.
        
                            UriBuilder
    reset()
        
    
    Resets all UriBuilder options to their default value.
Note: This won't reset the Request that is attached to this UriBuilder (setRequest())
        
                            string
    uriFor(string $actionName, array $controllerArguments = [], string $controllerName = null, string $packageKey = null, string $subPackageKey = null)
        
    
    Creates an URI used for linking to an Controller action.
        
                    protected        array
    addNamespaceToArguments(array $arguments, ActionRequest $currentRequest)
        
    
    Adds the argument namespace of the current request to the specified arguments.
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 ) )
        
                            string
    build(array $arguments = [])
        
    
    Builds the URI
        
                    protected        array
    mergeArgumentsWithRequestArguments(array $arguments)
        
    
    Merges specified arguments with arguments from request.
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        string
    getRequestNamespacePath(ActionRequest $request)
        
    
    Get the path of the argument namespaces of all parent requests.
Example: mainrequest.subrequest.subsubrequest