X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=public%2Findex.php;h=e6d0f75a4ce4a9fe449d1cd92c8f81c97b9c7570;hb=80ea76521e2ccbbfac1ac0f33f91af1739ead561;hp=649bb0aa4963bea552dfc8edbe937f8fa86a49d1;hpb=d7b9f83d24b7af987618921f555c9e5e2c2f4b95;p=mdref%2Fmdref diff --git a/public/index.php b/public/index.php index 649bb0a..e6d0f75 100644 --- a/public/index.php +++ b/public/index.php @@ -1,32 +1,30 @@ add("controllers", __DIR__ . "/../mdref"); +use mdref\Action; +use mdref\BaseUrl; +use mdref\Reference; +use mdref\ExceptionHandler; -use http\Controller; -use http\Controller\Url; +use http\Env\Request; +use http\Env\Response; -use http\Controller\Observer\Callback; -use http\Controller\Observer\Params; -use http\Controller\Observer\Action; -use http\Controller\Observer\View; -use http\Controller\Observer\Layout; +define("ROOT", dirname(__DIR__)); +define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*"))); +ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS); -$url = new Url; +if (!ini_get("date.timezone")) { + date_default_timezone_set("UTC"); +} -$ctl = new Controller; -$ctl->setDependency("baseUrl", $url); +spl_autoload_register(function($c) { + if (!strncmp($c, "mdref\\", 6)) { + return require ROOT . "/" . strtr($c, "\\", "/") . ".php"; + } +}); -$ctl->attach(new Params\Action); -$ctl->attach(new Action(["controllerPrefix" => "controllers\\"])); -$ctl->attach(new Callback(function(\http\Controller $ctl) use ($url) { - $ctl->getPayload()->baseUrl = $url; -})); -$ctl->attach(new View(["directory" => __DIR__ . "/../mdref/views"])); -$ctl->attach(new Layout(["directory" => __DIR__ . "/../mdref/views"])); - -$response = $ctl->notify()->getResponse(); -$response->send(); +$response = new Response; +$ehandler = new ExceptionHandler($response); +$reference = new Reference(explode(PATH_SEPARATOR, REFS)); +$action = new Action($reference, new Request, $response, new BaseUrl); +$action->handle();