コード例 #1
0
ファイル: Example.php プロジェクト: aladin1394/CM
 public function ajax_error(CM_Params $params, CM_Frontend_JavascriptContainer_View $handler, CM_Http_Response_View_Ajax $response)
 {
     $status = $params->getInt('status', 200);
     $message = $params->has('text') ? $params->getString('text') : null;
     $messagePublic = $params->getBoolean('public', false) ? $message : null;
     if (in_array($status, array(500, 599), true)) {
         $response->addHeaderRaw('HTTP/1.1 ' . $status . ' Internal Server Error');
         $response->sendHeaders();
         exit($message);
     }
     $exception = $params->getString('exception');
     if (!in_array($exception, array('CM_Exception', 'CM_Exception_AuthRequired'), true)) {
         $exception = 'CM_Exception';
     }
     throw new $exception($message, $messagePublic);
 }