Beispiel #1
0
 /**
  * Parses a request query string.
  *
  * @param string $httpRequestString Request string.
  * @param Routes $routes            Request routing routes.
  *
  * @static
  * @uses Core\Utils::parseHttpRequestString()
  *
  * @return array
  */
 public static function parseRequestQueryString($httpRequestString, Routes $routes)
 {
     if (Core\Config()->mode('url')) {
         $httpRequestString = trim(Core\Utils::replaceFirstOccurrence(Core\Config()->mode('url'), '', $httpRequestString), Core\Config()->ROUTER['separator']);
     } else {
         $httpRequestString = trim($httpRequestString, Core\Config()->ROUTER['separator']);
     }
     $requestElements = Core\Utils::parseHttpRequestString($httpRequestString, Core\Config()->ROUTER['separator']);
     $route = $routes->extractRoute($requestElements);
     $routedUrl = $routes->toRoute($route['pattern']);
     $elements = $route['maps_to'];
     foreach ($route['maps_to'] as $role => $value) {
         if ('*' === $value) {
             $_element = array_search(Core\Config()->ROUTER['variables_prefix'] . $role, $routedUrl);
             $elements[$role] = isset($requestElements[$_element]) ? $requestElements[$_element] : null;
         }
     }
     return $elements;
 }
Beispiel #2
0
 protected function setUp()
 {
     $this->routes = Routes::getInstance();
 }