protected function mergeArgumentsWithRequestArguments(array $arguments)
    {
        if ($this->request !== $this->request->getMainRequest()) {
            $subRequest = $this->request;
            while ($subRequest instanceof ActionRequest) {
                $requestArguments = (array)$subRequest->getArguments();

                // Reset arguments for the request that is bound to this UriBuilder instance
                if ($subRequest === $this->request) {
                    if ($this->addQueryString === false) {
                        $requestArguments = [];
                    } else {
                        foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                            unset($requestArguments[$argumentToBeExcluded]);
                        }
                    }
                } else {
                    // Remove all arguments of the current sub request if it's namespaced
                    if ($this->request->getArgumentNamespace() !== '') {
                        $requestNamespace = $this->getRequestNamespacePath($this->request);
                        if ($this->addQueryString === false) {
                            $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace);
                        } else {
                            foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                                $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace . '.' . $argumentToBeExcluded);
                            }
                        }
                    }
                }

                // Merge special arguments (package, subpackage, controller & action) from main request
                $requestPackageKey = $subRequest->getControllerPackageKey();
                if (!empty($requestPackageKey)) {
                    $requestArguments['@package'] = $requestPackageKey;
                }
                $requestSubpackageKey = $subRequest->getControllerSubpackageKey();
                if (!empty($requestSubpackageKey)) {
                    $requestArguments['@subpackage'] = $requestSubpackageKey;
                }
                $requestControllerName = $subRequest->getControllerName();
                if (!empty($requestControllerName)) {
                    $requestArguments['@controller'] = $requestControllerName;
                }
                $requestActionName = $subRequest->getControllerActionName();
                if (!empty($requestActionName)) {
                    $requestArguments['@action'] = $requestActionName;
                }
                $requestFormat = $subRequest->getFormat();
                if (!empty($requestFormat)) {
                    $requestArguments['@format'] = $requestFormat;
                }

                if (count($requestArguments) > 0) {
                    $requestArguments = $this->addNamespaceToArguments($requestArguments, $subRequest);
                    $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
                }

                $subRequest = $subRequest->getParentRequest();
            }
        } elseif ($this->addQueryString === true) {
            $requestArguments = $this->request->getArguments();
            foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                unset($requestArguments[$argumentToBeExcluded]);
            }

            if ($requestArguments !== []) {
                $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
            }
        }

        return $arguments;
    }
protected function mergeArgumentsWithRequestArguments(array $arguments)
    {
        if ($this->request !== $this->request->getMainRequest()) {
            $subRequest = $this->request;
            while ($subRequest instanceof ActionRequest) {
                $requestArguments = (array)$subRequest->getArguments();

                // Reset arguments for the request that is bound to this UriBuilder instance
                if ($subRequest === $this->request) {
                    if ($this->addQueryString === false) {
                        $requestArguments = [];
                    } else {
                        foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                            unset($requestArguments[$argumentToBeExcluded]);
                        }
                    }
                } else {
                    // Remove all arguments of the current sub request if it's namespaced
                    if ($this->request->getArgumentNamespace() !== '') {
                        $requestNamespace = $this->getRequestNamespacePath($this->request);
                        if ($this->addQueryString === false) {
                            $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace);
                        } else {
                            foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                                $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace . '.' . $argumentToBeExcluded);
                            }
                        }
                    }
                }

                // Merge special arguments (package, subpackage, controller & action) from main request
                $requestPackageKey = $subRequest->getControllerPackageKey();
                if (!empty($requestPackageKey)) {
                    $requestArguments['@package'] = $requestPackageKey;
                }
                $requestSubpackageKey = $subRequest->getControllerSubpackageKey();
                if (!empty($requestSubpackageKey)) {
                    $requestArguments['@subpackage'] = $requestSubpackageKey;
                }
                $requestControllerName = $subRequest->getControllerName();
                if (!empty($requestControllerName)) {
                    $requestArguments['@controller'] = $requestControllerName;
                }
                $requestActionName = $subRequest->getControllerActionName();
                if (!empty($requestActionName)) {
                    $requestArguments['@action'] = $requestActionName;
                }
                $requestFormat = $subRequest->getFormat();
                if (!empty($requestFormat)) {
                    $requestArguments['@format'] = $requestFormat;
                }

                if (count($requestArguments) > 0) {
                    $requestArguments = $this->addNamespaceToArguments($requestArguments, $subRequest);
                    $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
                }

                $subRequest = $subRequest->getParentRequest();
            }
        } elseif ($this->addQueryString === true) {
            $requestArguments = $this->request->getArguments();
            foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                unset($requestArguments[$argumentToBeExcluded]);
            }

            if ($requestArguments !== []) {
                $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
            }
        }

        return $arguments;
    }
protected function mergeArgumentsWithRequestArguments ( array $ arguments ) { if ( $ this -> request !== $ this -> request -> getMainRequest ( ) ) { $ subRequest = $ this -> request ; while ( $ subRequest instanceof ActionRequest ) { $ requestArguments = ( array ) $ subRequest -> getArguments ( ) ; // Reset arguments for the request that is bound to this UriBuilder instance if ( $ subRequest === $ this -> request ) { if ( $ this -> addQueryString === false ) { $ requestArguments = [ ] ; } else { foreach ( $ this -> argumentsToBeExcludedFromQueryString as $ argumentToBeExcluded ) { unset ( $ requestArguments [ $ argumentToBeExcluded ] ) ; } } } else { // Remove all arguments of the current sub request if it's namespaced if ( $ this -> request -> getArgumentNamespace ( ) !== '' ) { $ requestNamespace = $ this -> getRequestNamespacePath ( $ this -> request ) ; if ( $ this -> addQueryString === false ) { $ requestArguments = Arrays :: unsetValueByPath ( $ requestArguments , $ requestNamespace ) ; } else { foreach ( $ this -> argumentsToBeExcludedFromQueryString as $ argumentToBeExcluded ) { $ requestArguments = Arrays :: unsetValueByPath ( $ requestArguments , $ requestNamespace . '.' . $ argumentToBeExcluded ) ; } } } } // Merge special arguments (package, subpackage, controller & action) from main request $ requestPackageKey = $ subRequest -> getControllerPackageKey ( ) ; if ( ! empty ( $ requestPackageKey ) ) { $ requestArguments [ '@package' ] = $ requestPackageKey ; } $ requestSubpackageKey = $ subRequest -> getControllerSubpackageKey ( ) ; if ( ! empty ( $ requestSubpackageKey ) ) { $ requestArguments [ '@subpackage' ] = $ requestSubpackageKey ; } $ requestControllerName = $ subRequest -> getControllerName ( ) ; if ( ! empty ( $ requestControllerName ) ) { $ requestArguments [ '@controller' ] = $ requestControllerName ; } $ requestActionName = $ subRequest -> getControllerActionName ( ) ; if ( ! empty ( $ requestActionName ) ) { $ requestArguments [ '@action' ] = $ requestActionName ; } $ requestFormat = $ subRequest -> getFormat ( ) ; if ( ! empty ( $ requestFormat ) ) { $ requestArguments [ '@format' ] = $ requestFormat ; } if ( count ( $ requestArguments ) > 0 ) { $ requestArguments = $ this -> addNamespaceToArguments ( $ requestArguments , $ subRequest ) ; $ arguments = Arrays :: arrayMergeRecursiveOverrule ( $ requestArguments , $ arguments ) ; } $ subRequest = $ subRequest -> getParentRequest ( ) ; } } elseif ( $ this -> addQueryString === true ) { $ requestArguments = $ this -> request -> getArguments ( ) ; foreach ( $ this -> argumentsToBeExcludedFromQueryString as $ argumentToBeExcluded ) { unset ( $ requestArguments [ $ argumentToBeExcluded ] ) ; } if ( $ requestArguments !== [ ] ) { $ arguments = Arrays :: arrayMergeRecursiveOverrule ( $ requestArguments , $ arguments ) ; } } return $ 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)

@param array $arguments
@return array
Merges specified arguments with arguments from request .