private function finish() { $routeInfo = $this->dispatcher->dispatch($this->request->method(), $this->request->uri()); switch ($routeInfo[0]) { case Dispatcher::NOT_FOUND: $this->response->code(404); $this->response->getLayout()->content = (new Controller())->error404(); break; case Dispatcher::METHOD_NOT_ALLOWED: $allowedMethods = $routeInfo[1]; $this->response->code(415); break; case Dispatcher::FOUND: $handler = explode('::', $routeInfo[1]); /** @var Controller $class */ $class = $handler[0]; $method = $handler[1]; $vars = $routeInfo[2]; $this->response->type($class::type()); $this->response->getLayout()->content = call_user_func_array([new $class(), $method], $vars); break; } $this->response->output(); }