fix class vs constant issue
[mdref/mdref] / public / index.php
index 649bb0aa4963bea552dfc8edbe937f8fa86a49d1..853c0916398ec77e7878c34c8ec99ff8d5aaa2e0 100644 (file)
@@ -1,32 +1,27 @@
 <?php
-while (ob_get_level() && ob_end_clean());
 
-$loader = require __DIR__ . "/../vendor/autoload.php";
-/* @var $loader \Composer\Autoload\ClassLoader */
-$loader->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__));
 
+#ini_set("open_basedir", ROOT.":".REFS);
 
-$url = new Url;
+$loader = require ROOT . "/vendor/autoload.php";
+/* @var $loader \Composer\Autoload\ClassLoader */
+$loader->add("mdref", ROOT);
 
-$ctl = new Controller;
-$ctl->setDependency("baseUrl", $url);
+new ExceptionHandler;
 
-$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"]));
+$reference = new Reference(($refs = getenv("REFPATH")) ? explode(PATH_SEPARATOR, $refs) : glob(ROOT."/refs/*"));
+$action = new Action($reference, new Request, new Response, new BaseUrl);
 
-$response = $ctl->notify()->getResponse();
+ob_start($response);
+$action->handle();
+ob_end_flush();
 $response->send();