Example #1
0
 /**
  * @test
  * @expectedException \InvalidArgumentException
  */
 public function unsetValueByPathThrowsExceptionIfPathIsNoArrayOrString()
 {
     $array = array('Foo' => array('Bar' => array('Baz' => array(2 => 'the value'))));
     \TYPO3\FLOW3\Utility\Arrays::unsetValueByPath($array, NULL);
 }
Example #2
0
 /**
  * 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 void
  */
 protected function mergeArgumentsWithRequestArguments(array &$arguments)
 {
     $requestArguments = array();
     $mainRequest = $this->request->getMainRequest();
     $isSubRequest = $this->request !== $mainRequest;
     if ($isSubRequest) {
         $requestArguments = $mainRequest->getArguments();
         // remove all arguments of the current sub request
         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
         $mainRequestPackageKey = $mainRequest->getControllerPackageKey();
         if (!empty($mainRequestPackageKey)) {
             $requestArguments['@package'] = $mainRequestPackageKey;
         }
         $mainRequestSubpackageKey = $mainRequest->getControllerSubpackageKey();
         if (!empty($mainRequestSubpackageKey)) {
             $requestArguments['@subpackage'] = $mainRequestSubpackageKey;
         }
         $mainRequestControllerName = $mainRequest->getControllerName();
         if (!empty($mainRequestControllerName)) {
             $requestArguments['@controller'] = $mainRequestControllerName;
         }
         $mainRequestActionName = $mainRequest->getControllerActionName();
         if (!empty($mainRequestActionName)) {
             $requestArguments['@action'] = $mainRequestActionName;
         }
     } elseif ($this->addQueryString === TRUE) {
         $requestArguments = $this->request->getArguments();
         foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
             unset($requestArguments[$argumentToBeExcluded]);
         }
     }
     if (count($requestArguments) === 0) {
         return;
     }
     $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
 }
Example #3
0
 /**
  * Checks whether $routeValues contains elements which correspond to this Dynamic Route Part.
  * If a corresponding element is found in $routeValues, this element is removed from the array.
  *
  * @param array $routeValues An array with key/value pairs to be resolved by Dynamic Route Parts.
  * @return boolean TRUE if current Route Part could be resolved, otherwise FALSE
  */
 public final function resolve(array &$routeValues)
 {
     $this->value = NULL;
     if ($this->name === NULL || $this->name === '') {
         return FALSE;
     }
     $valueToResolve = $this->findValueToResolve($routeValues);
     if (!$this->resolveValue($valueToResolve)) {
         return FALSE;
     }
     if ($this->lowerCase) {
         $this->value = strtolower($this->value);
     }
     $routeValues = \TYPO3\FLOW3\Utility\Arrays::unsetValueByPath($routeValues, $this->name);
     return TRUE;
 }