style fixes
[mdref/mdref] / public / index.php
index d4518cd3a26691a5387aea740d173ea90cc09703..58ec5fe565cec71e20192088a1b0592fbc4b6099 100644 (file)
@@ -1,25 +1,26 @@
 <?php
 
+use mdref\Action;
+use mdref\BaseUrl;
+use mdref\Reference;
+use mdref\ExceptionHandler;
+
+use http\Env\Request;
+use http\Env\Response;
+
 define("ROOT", dirname(__DIR__));
 define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*")));
 
-$loader = require __DIR__ . "/../vendor/autoload.php";
-/* @var $loader \Composer\Autoload\ClassLoader */
-$loader->add("mdref", ROOT);
+ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS);
 
-use http\Controller;
-use http\Controller\Url;
-use http\Controller\Observer\Layout;
-
-use mdref\ExceptionHandler;
-use mdref\Action;
+spl_autoload_register(function($c) {
+       if (!strncmp($c, "mdref\\", 6)) {
+               return require ROOT . "/" . strtr($c, "\\", "/") . ".php";
+       }
+});
 
 new ExceptionHandler;
 
-$ctl = new Controller;
-$ctl->setDependency("baseUrl", new Url)
-       ->attach(new Action)
-       ->attach(new Layout)
-       ->notify()
-       ->getResponse()
-       ->send();
+$reference = new Reference(explode(PATH_SEPARATOR, REFS));
+$action = new Action($reference, new Request, new Response, new BaseUrl);
+$action->handle();