/**
  * @expectedException \Exception
  */
 public function testPassingExistentControllerWithValidMethodWithoutProperParameters()
 {
     $controller = 'ServerInfo';
     $method = 'getInfo';
     $parameters = ['container' => $this->container, 'format' => 'json'];
     $strategy = new RouteFound($controller, $method, $parameters);
     $strategy->render();
 }
Example #2
0
 /**
  * Handle route
  *
  * @param Request $request
  */
 public function handle(Request $request)
 {
     $context = new RequestContext();
     $context->fromRequest($request);
     $matcher = new UrlMatcher($this->routes, $context);
     try {
         $attributes = $matcher->match($request->getPathInfo());
     } catch (ResourceNotFoundException $e) {
         $response = new JsonResponse();
         $response->setData(['error' => 'Route not found.']);
         $response->send();
         return;
     }
     $controller = $attributes['controller'];
     $method = $attributes['method'];
     unset($attributes['method']);
     unset($attributes['controller']);
     $parameters = array_merge(['container' => $this->container], $attributes);
     $route = new RouteFound($controller, $method, $parameters);
     $route->render();
 }