Example #1
0
 /**
  * {@inheritDoc}
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $context = new RequestContext();
     $context->fromRequest($request);
     $urlMatcher = new UrlMatcher($this->routeCollection, $context);
     try {
         $parameters = $urlMatcher->match($request->getPathInfo());
         //@TODO improve request bindings
         $request->attributes->replace($parameters);
     } catch (ResourceNotFoundException $e) {
         throw new NotFoundHttpException(sprintf("No route found for url \"%s\"", $request->getPathInfo()), $e);
     } catch (MethodNotAllowedException $e) {
         throw new MethodNotAllowedHttpException($e->getAllowedMethods(), sprintf("Method %s is not allowed for url \"%s\"", $request->getMethod(), $request->getPathInfo()), $e);
     }
     $this->stack = $this->getStack($parameters);
     return $this->stack->handle($request, $type, $catch);
 }