Пример #1
0
 private function handleRequest(Request $request, array $session)
 {
     $path = $request->path;
     $routeMatch = $this->findRoute($path);
     if (!$routeMatch) {
         throw new NoMatchedRouteException($path);
     }
     $controllerName = $this->transformPath(trim($routeMatch['controller']));
     $action = $this->transformPath(trim($routeMatch['action']));
     self::verifyControllerAndAction($routeMatch->getRoute()->getName(), $path, $controllerName, $action);
     $controller = $this->createController($controllerName);
     if (!$controller) {
         throw new ControllerConstructionException("Unable to create controller for path \"{$path}\"");
     }
     $result = $controller->execute(new ActionExecutionContext($request, $session, $this->routes, $routeMatch, $this->binders, $action));
     if (!$result instanceof ActionResult) {
         throw new LogicException("The action \"{$controllerName}::{$action}\" did not return an instance of \\Facilius\\ActionResult");
     }
     $result->execute(new ActionResultContext($action, $request, $this->response, $routeMatch, $controller, $this->routes));
     $this->response->flush();
 }