Exemple #1
0
 public function dispatch($uri)
 {
     $path = $this->normalizePath(parse_url($uri, PHP_URL_PATH));
     $exception_more = array();
     do {
         if ($base_uri = $this->base_uri) {
             if (strpos($path . '/', $base_uri . '/') !== 0) {
                 break;
             }
             $path = $this->normalizePath(substr($path, strlen($base_uri)));
         }
         $exception_more['path'] = $path;
         if (!($result = $this->rewrite($path) ?: $this->convert($path))) {
             break;
         }
         list($class, $params, ) = $result;
         $exception_more['controller'] = $class;
         $exception_more['params'] = $params;
         if (!class_exists($class)) {
             break;
         }
         return $result;
     } while (false);
     $exception = HTTP\Exception::factory(HTTP::NOT_FOUND);
     $exception->setMore($exception_more);
     throw $exception;
 }
Exemple #2
0
 protected function halt()
 {
     throw User::current()->hasRole(ROLE_ANONYMOUS) ? HTTP\Exception::factory(401) : HTTP\Exception::factory(403);
     // 403
 }