setRootDir($rootDir); $app->setRequestUri($_SERVER['REQUEST_URI']); // Route the application $stat = $app->route(); switch ($stat) { case WebApplication::RUNNING_WORKFLOW: include "sysGeneric.php"; break; case WebApplication::RUNNING_API: $app->run(WebApplication::SERVICE_API); break; case WebApplication::RUNNING_OAUTH2: $app->run(WebApplication::SERVICE_OAUTH2); break; case WebApplication::RUNNING_INDEX: $response = new Response(file_get_contents("index.html"), 302); $response->send(); break; case WebApplication::RUNNING_DEFAULT: $response = new Response("", 302); //TODO compose this def url with configuration data from env.ini $response->setHeader("location", "/sys/en/neoclassic/login/login"); $response->send(); break; } } catch (RBACException $e) { handleRBACException($e); } catch (Exception $e) { //handleGeneralException($e, $rootDir); $view = new PhtmlView($rootDir . "framework/src/templates/Exception.phtml"); $view->set("message", $e->getMessage()); $view->set("exception", $e); $response = new Response($view->getOutput(), 503); $response->send(); } /** * Handle the application state based on routing status. * * @param int $stat * @param WebApplication $app */ function handleApplicationState(int $stat, WebApplication $app): void { } /** * Handle RBAC exceptions by redirecting to the specified path. * * @param RBACException $e */ function handleRBACException(RBACException $e): void { G::header('location: ' . $e->getPath()); } /** * Handle general exceptions by rendering an error view. * * @param Exception $e * @param string $rootDir */ function handleGeneralException(Exception $e, string $rootDir): void { $view = new PhtmlView($rootDir . "framework/src/templates/Exception.phtml"); $view->set("message", $e->getMessage()); $view->set("exception", $e); $response = new Response($view->getOutput(), 503); $response->send(); }