Exemple #1
0
 public function resolve(RequestInterface $request, Context $context)
 {
     $routingCollection = $this->routingParser->getCollection();
     $method = $request->getMethod();
     $pathMatcher = new PathMatcher($request->getUri()->getPath());
     foreach ($routingCollection as $routing) {
         $parameters = array();
         if (in_array($method, $routing[RoutingCollection::ROUTING_METHODS]) && $pathMatcher->match($routing[RoutingCollection::ROUTING_PATH], $parameters)) {
             $source = $routing[RoutingCollection::ROUTING_SOURCE];
             if ($source[0] == '~') {
                 $request->setUri(new Uri(substr($source, 1)));
                 return $this->resolve($request, $context);
             }
             $context->set(Context::KEY_PATH, $routing[RoutingCollection::ROUTING_PATH]);
             $context->set(Context::KEY_FRAGMENT, $parameters);
             $context->set(Context::KEY_SOURCE, $source);
             return $request;
         }
     }
     return null;
 }