style fixes
[mdref/mdref] / public / index.php
index 23a1be2cf1a8595337669918a3438a80f4ef27fe..58ec5fe565cec71e20192088a1b0592fbc4b6099 100644 (file)
@@ -1,27 +1,26 @@
 <?php
 
-define("ROOT", dirname(__DIR__));
-define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*")));
+use mdref\Action;
+use mdref\BaseUrl;
+use mdref\Reference;
+use mdref\ExceptionHandler;
 
-ini_set("open_basedir", ROOT.":".REFS);
+use http\Env\Request;
+use http\Env\Response;
 
-$loader = require ROOT . "/vendor/autoload.php";
-/* @var $loader \Composer\Autoload\ClassLoader */
-$loader->add("mdref", ROOT);
+define("ROOT", dirname(__DIR__));
+define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*")));
 
-use http\Controller;
-use http\Controller\Url;
-use http\Controller\Observer\Layout;
+ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS);
 
-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();