コード例 #1
0
ファイル: ShinyBlog.php プロジェクト: nekudo/shiny_blog
 /**
  * Tries to find a route matching the current request. If found the defined action is called.
  */
 protected function dispatch()
 {
     $httpMethod = $_SERVER['REQUEST_METHOD'];
     $uri = rawurldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
     $routeInfo = $this->dispatcher->dispatch($httpMethod, $uri);
     if (!isset($routeInfo[0])) {
         throw new RuntimeException('Could not dispatch request.');
     }
     switch ($routeInfo[0]) {
         case FastRoute\Dispatcher::NOT_FOUND:
             $responder = new NotFoundResponder($this->config);
             $responder->__invoke();
             break;
         case FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
             $responder = new HttpResponder($this->config);
             $responder->methodNotAllowed();
             break;
         case FastRoute\Dispatcher::FOUND:
             $handler = $routeInfo[1];
             $arguments = $routeInfo[2];
             $this->runAction($handler, $arguments);
             break;
         default:
             throw new RuntimeException('Could not dispatch request.');
     }
 }
コード例 #2
0
ファイル: HtmlResponder.php プロジェクト: nekudo/shiny_blog
 public function __construct(array $config)
 {
     parent::__construct($config);
     $this->themeFolder = $config['themesFolder'] . '/' . $config['theme'] . '/';
 }