Exemplo n.º 1
0
 public function __construct()
 {
     $this->sources = new Sequence();
     $this->sources->push(http\HttpGet::getInstance());
     $this->sources->push(http\HttpPut::getInstance());
     $this->sources->push(http\HttpPost::getInstance());
     $this->sources->push(router\RouteArgs::getInstance());
 }
Exemplo n.º 2
0
 public function run()
 {
     $handler = $this->find()->getOrThrow(PageNotFoundException::class);
     RouteArgs::getInstance()->setMapData($handler["args"]);
     if (is_string($handler["action"])) {
         if (!class_exists($handler["action"])) {
             throw new PageNotFoundException();
         }
         $instance = new $handler["action"]();
         if (!$instance instanceof RouteHandler) {
             throw new WrongRouteHandlerException();
         }
         $method = "do" . ucfirst(strtolower($_SERVER["REQUEST_METHOD"]));
         if (!method_exists($instance, $method)) {
             throw new NotImplementedException();
         }
         Injector::run(array($instance, $method));
     } else {
         if (is_callable($handler["action"])) {
             Injector::run($handler["action"]);
         } else {
             throw new ApplicationException("Invalid action handler!");
         }
     }
 }