default backend/api route

This commit is contained in:
crispycat 2024-10-06 23:19:02 -04:00
parent 08cdb94dae
commit cbe1cc1dd2
3 changed files with 4 additions and 3 deletions

View File

@ -61,7 +61,7 @@
"src" => WROOT . "/media/system/crispedit/editor.js"
];
$route = $this->getRoute("backend");
$route = $this->getRoute("backend", "dashboard");
if (!$route) throw new NotFoundException();
$this->setRouteLayout($route);

View File

@ -17,11 +17,11 @@
use \Crispage\Request\Route;
abstract class SubRouterAction extends \Crispage\Framework\Action {
public function getRoute(string $scope): ?Route {
public function getRoute(string $scope, string $default = "default"): ?Route {
return $this->app->router->getRoute(
strval(
$this->data["route"] ??
$this->app->request->params["route"] ?? "default"
$this->app->request->params["route"] ?? $default
),
$scope
);

View File

@ -39,6 +39,7 @@
new Route("/reset_password", "\\Crispage\\Actions\\PasswordResetAction", []),
new Route("/user_settings", "\\Crispage\\Actions\\UserSettingsAction", []),
new Route("/backend", "\\Crispage\\Actions\\BackendSubRouter", static::RDATA_BACKEND),
new Route("/api", "\\Crispage\\Actions\\APISubRouter", static::RDATA_API)
],
"backend" => [
new Route("dashboard", "\\Crispage\\Actions\\Backend\\DashboardAction", static::RDATA_BACKEND),