X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=mdref%2FAction.php;h=d85e300fed5fc36663505d57943372efe4cd0959;hb=6a97dab17a6ee9a5a87ebb396da78fe87847794d;hp=5737cfeba629a4ebff203efa560b660cdf83994b;hpb=88eccca8a8f42b9432dd35ad78d7b3fa999b21b1;p=mdref%2Fmdref diff --git a/mdref/Action.php b/mdref/Action.php index 5737cfe..d85e300 100644 --- a/mdref/Action.php +++ b/mdref/Action.php @@ -9,11 +9,11 @@ use http\Controller\Observer; */ class Action extends Observer { - private function serveReference(\http\Url $url, \http\Controller\Payload $payload) { + private function serveReference(\http\Url $url, \stdClass $payload) { $finder = new Finder($this->baseUrl, REFS); $path = $finder->find($url); $payload->listing = new RefListing($path, - $finder->glob($path, "/[_a-zA-Z]*.md")); + $finder->glob($path, "/[:_a-zA-Z]*.md")); $payload->title = $payload->listing->getSelf()->formatLink(); $payload->refs = $finder; if ($path->isFile()) { @@ -24,7 +24,7 @@ class Action extends Observer } } - private function serveInternal(\http\Url $url, \http\Controller\Payload $payload) { + private function serveInternal(\http\Url $url, \stdClass $payload) { $finder = new Finder($this->baseUrl, ROOT); $path = $finder->find($url, ""); if ($path->isFile("")) { @@ -65,14 +65,18 @@ class Action extends Observer function update(\SplSubject $ctl) { /* @var \http\Controller $ctl */ try { - $pld = $ctl->getPayload(); + $pld = new \stdClass; + $ctl[Observer\View::class] = function() use($pld) { + return $pld; + }; + $pld->baseUrl = $this->baseUrl; $url = $this->baseUrl->mod($ctl->getRequest()->getRequestUrl()); - + $pld->permUrl = implode("/", $this->baseUrl->params($url)); if ($this->serveReference($url, $pld) || $this->serveInternal($url, $pld)) { return; } elseif ($this->servePublic($url, $ctl->getResponse())) { - $ctl->detachAll("\\http\\Controller\\Observer\\View"); + $ctl->detachAll(Observer\View::class); return; } @@ -80,8 +84,10 @@ class Action extends Observer if (strcmp($url->path, $this->baseUrl->path)) { throw new \http\Controller\Exception(404, "Could not find '$url'"); } - } catch (\Exception $e) { - $ctl->getPayload()->exception = $e; + } catch (\Exception $exception) { + $ctl[Observer\View::class] = function() use($exception) { + return compact("exception"); + }; } } }