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