2024-07-11 17:21:33 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
The app container exists to be a dependency container for the game.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class App
|
|
|
|
{
|
|
|
|
public static Database $db;
|
|
|
|
public static Request $req;
|
|
|
|
|
|
|
|
public function __construct(string $dbPath)
|
|
|
|
{
|
|
|
|
self::$req = new Request(); // the current request
|
|
|
|
self::$db = new Database($dbPath); // the database
|
|
|
|
}
|
2024-07-11 18:17:51 -05:00
|
|
|
|
|
|
|
public function route(string $uri, array $routes)
|
|
|
|
{
|
|
|
|
// check if the module exists
|
|
|
|
if (isset($routes[$module])) {
|
|
|
|
// if the module exists, call the module's handle method
|
|
|
|
$routes[$module]($this);
|
|
|
|
} else {
|
|
|
|
// if the module does not exist, render a 404 page
|
|
|
|
$this->render('404', [
|
|
|
|
'title' => '404',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2024-07-11 17:21:33 -05:00
|
|
|
}
|