コード例 #1
0
ファイル: Router.php プロジェクト: wcoder/PHPj
 public function __construct(Request $request)
 {
     try {
         $this->url = $request->getUrl();
         $this->method = $request->getMethod();
         $this->initModule();
         Config::set($this->loadConfig());
         $this->handler();
         Config::set($this->getControlParams());
         $this->loadBootstrap();
         $this->loadController();
         $this->callAction();
     } catch (\Exception $e) {
         $this->getError($e->getMessage());
     }
 }
コード例 #2
0
ファイル: Response.php プロジェクト: wcoder/PHPj
 /**
  * @param int $error_code
  * @param bool $error_view
  * @param string $error_content
  */
 public static function status($error_code, $error_view = false, $error_content = '')
 {
     switch ($error_code) {
         case 301:
             $status = 'Moved Permanently';
             break;
         case 400:
             $status = 'Bad Request';
             break;
         case 401:
             $status = 'Unauthorized';
             break;
         case 402:
             $status = 'Unauthorized';
             break;
         case 403:
             $status = 'Forbidden';
             break;
         case 404:
             $status = 'Not Found';
             break;
         case 407:
             $status = 'Proxy Authentication Required';
             break;
         case 408:
             $status = 'Request Time-out';
             break;
         case 429:
             $status = 'Too many requests';
             break;
         case 500:
             $status = 'Internal Server Error';
             break;
         case 502:
             $status = 'Bad Gateway';
             break;
         case 503:
             $status = 'Service Unavailable';
             break;
         case 504:
             $status = 'Gateway Timeout';
             break;
         default:
             $status = '';
             break;
     }
     self::sendHeader(Request::getHttpProtocol() . " {$error_code} {$status}");
     self::sendHeader("Status: {$error_code} {$status}");
     // если указан вывод шаблона
     if ($error_view) {
         exit(self::getErrorView($error_code, $status, $error_content));
     }
 }