Ejemplo n.º 1
0
 public function testCreateFromRequest()
 {
     $request = new Request('GET', '/home', 'HTTP', '1.1');
     $context = RequestContext::createFromRequest($request);
     $this->assertSame('GET', $context->getMethod());
     $this->assertSame('/home', $context->getPath());
     $this->assertSame('GET /home', (string) $context);
 }
Ejemplo n.º 2
0
 private function doHandle(RequestInterface $request)
 {
     $context = RequestContext::createFromRequest($request);
     $action = $this->controllers->createController($this->router->match($context));
     $response = call_user_func_array($action, [$request]);
     if (!$response instanceof ResponseInterface) {
         throw new \RuntimeException('A controller must return a Response object.');
     }
     return $response;
 }
Ejemplo n.º 3
0
 private function doHandle(RequestInterface $request)
 {
     $router = $this->getService('router');
     $factory = $this->getService('controller_factory');
     $context = RequestContext::createFromRequest($request);
     $action = $factory->createController($router->match($context));
     if ($action instanceof AbstractAction) {
         $action->setServiceLocator($this->dic);
     }
     $response = call_user_func_array($action, [$request]);
     if (!$response instanceof ResponseInterface) {
         throw new \RuntimeException('A controller must return a Response object.');
     }
     return $response;
 }
Ejemplo n.º 4
0
 public function onKernelRequest(KernelEvent $event)
 {
     $request = $event->getRequest();
     $context = RequestContext::createFromRequest($request);
     $request->setAttributes($this->router->match($context));
 }