Skip to content

Commit

Permalink
feat(controller) erreur 404 facile dans les controleurs
Browse files Browse the repository at this point in the history
  • Loading branch information
beMang committed Sep 3, 2018
1 parent 2dd4461 commit 70e0ba0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/Core/BackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,15 @@ protected function redirectToRoute(string $route, int $status = 301) :ResponseIn
throw new \InvalidArgumentException('Route inconnue ou invalide');
}
}

protected function error() :ResponseInterface
{
$errorPageConfig = Config::getInstance()->get('errorPage');
$controllerClass = '\\app\\Controllers\\' . $errorPageConfig[0];
$route = new Route('404', $errorPageConfig[0], $errorPageConfig[1]);
$controller = new $controllerClass($route, $this->request);
$response = $controller->execute();
$response = $response->withStatus(404);
return $response;
}
}

0 comments on commit 70e0ba0

Please sign in to comment.