/**
  * Iterate through the configured modules, find the matching module and set
  * the route path accordingly
  *
  * @param array $value (contains action, controller and package of the module controller)
  * @return boolean
  */
 protected function resolveValue($value)
 {
     if (is_array($value)) {
         $this->value = isset($value['@action']) && $value['@action'] !== 'index' ? $value['@action'] : '';
         if ($this->value !== '' && isset($value['@format'])) {
             $this->value .= '.' . $value['@format'];
         }
         $exceedingArguments = array();
         foreach ($value as $argumentKey => $argumentValue) {
             if (substr($argumentKey, 0, 1) !== '@' && substr($argumentKey, 0, 2) !== '__') {
                 $exceedingArguments[$argumentKey] = $argumentValue;
             }
         }
         if ($exceedingArguments !== array()) {
             $exceedingArguments = Arrays::removeEmptyElementsRecursively($exceedingArguments);
             $exceedingArguments = $this->persistenceManager->convertObjectsToIdentityArrays($exceedingArguments);
             $queryString = http_build_query(array($this->name => $exceedingArguments), null, '&');
             if ($queryString !== '') {
                 $this->value .= '?' . $queryString;
             }
         }
     }
     return true;
 }
 /**
  * @test
  */
 public function removeEmptyElementsRecursivelyRemovesEmptySubArrays()
 {
     $array = array('EmptyElement' => array(), 'Foo' => array('Bar' => array('Baz' => array('AnotherEmptyElement' => NULL))), 'NotNull' => 123);
     $expectedResult = array('NotNull' => 123);
     $actualResult = \TYPO3\Flow\Utility\Arrays::removeEmptyElementsRecursively($array);
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * Checks whether $routeValues can be resolved to a corresponding uri.
  * If all Route Parts can resolve one or more of the $routeValues, TRUE is
  * returned and $this->matchingURI contains the generated URI (excluding
  * protocol and host).
  *
  * @param array $routeValues An array containing key/value pairs to be resolved to uri segments
  * @return boolean TRUE if this Route corresponds to the given $routeValues, otherwise FALSE
  * @throws InvalidRoutePartValueException
  * @see getMatchingUri()
  */
 public function resolves(array $routeValues)
 {
     $this->resolvedUriPath = null;
     if ($this->uriPattern === null) {
         return false;
     }
     if (!$this->isParsed) {
         $this->parse();
     }
     $resolvedUriPath = '';
     $remainingDefaults = $this->defaults;
     $requireOptionalRouteParts = false;
     $matchingOptionalUriPortion = '';
     /** @var $routePart RoutePartInterface */
     foreach ($this->routeParts as $routePart) {
         if (!$routePart->resolve($routeValues)) {
             if (!$routePart->hasDefaultValue()) {
                 return false;
             }
         }
         if ($routePart->getName() !== null) {
             $remainingDefaults = Arrays::unsetValueByPath($remainingDefaults, $routePart->getName());
         }
         $routePartValue = null;
         if ($routePart->hasValue()) {
             $routePartValue = $routePart->getValue();
             if (!is_string($routePartValue)) {
                 throw new InvalidRoutePartValueException('RoutePart::getValue() must return a string after calling RoutePart::resolve(), got ' . (is_object($routePartValue) ? get_class($routePartValue) : gettype($routePartValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".');
             }
         }
         $routePartDefaultValue = $routePart->getDefaultValue();
         if ($routePartDefaultValue !== null && !is_string($routePartDefaultValue)) {
             throw new InvalidRoutePartValueException('RoutePart::getDefaultValue() must return a string, got ' . (is_object($routePartDefaultValue) ? get_class($routePartDefaultValue) : gettype($routePartDefaultValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".');
         }
         if (!$routePart->isOptional()) {
             $resolvedUriPath .= $routePart->hasValue() ? $routePartValue : $routePartDefaultValue;
             $requireOptionalRouteParts = false;
             continue;
         }
         if ($routePart->hasValue() && strtolower($routePartValue) !== strtolower($routePartDefaultValue)) {
             $matchingOptionalUriPortion .= $routePartValue;
             $requireOptionalRouteParts = true;
         } else {
             $matchingOptionalUriPortion .= $routePartDefaultValue;
         }
         if ($requireOptionalRouteParts) {
             $resolvedUriPath .= $matchingOptionalUriPortion;
             $matchingOptionalUriPortion = '';
         }
     }
     if ($this->compareAndRemoveMatchingDefaultValues($remainingDefaults, $routeValues) !== true) {
         return false;
     }
     if (isset($routeValues['@format']) && $routeValues['@format'] === '') {
         unset($routeValues['@format']);
     }
     // add query string
     if (count($routeValues) > 0) {
         $routeValues = Arrays::removeEmptyElementsRecursively($routeValues);
         $routeValues = $this->persistenceManager->convertObjectsToIdentityArrays($routeValues);
         if (!$this->appendExceedingArguments) {
             $internalArguments = $this->extractInternalArguments($routeValues);
             if ($routeValues !== array()) {
                 return false;
             }
             $routeValues = $internalArguments;
         }
         $queryString = http_build_query($routeValues, null, '&');
         if ($queryString !== '') {
             $resolvedUriPath .= strpos($resolvedUriPath, '?') !== false ? '&' . $queryString : '?' . $queryString;
         }
     }
     $this->resolvedUriPath = $resolvedUriPath;
     return true;
 }