Ejemplo n.º 1
0
 /**
  *	Ethna_Errorクラスのコンストラクタ
  *
  *	@access	public
  *	@param	int		$level				エラーレベル
  *	@param	string	$message			エラーメッセージ
  *	@param	int		$code				エラーコード
  *	@param	array	$userinfo			エラー追加情報(エラーコード以降の全ての引数)
  */
 function Ethna_Error($message = null, $code = null, $mode = null, $options = null)
 {
     $controller =& Ethna_Controller::getInstance();
     if ($controller !== null) {
         $this->i18n =& $controller->getI18N();
     }
     // $options以降の引数->$userinfo
     if (func_num_args() > 4) {
         $userinfo = array_slice(func_get_args(), 4);
         if (count($userinfo) == 1) {
             if (is_array($userinfo[0])) {
                 $userinfo = $userinfo[0];
             } else {
                 if (is_null($userinfo[0])) {
                     $userinfo = array();
                 }
             }
         }
     } else {
         $userinfo = array();
     }
     // メッセージ補正処理
     if (is_null($message)) {
         // $codeからメッセージを取得する
         $message = $controller->getErrorMessage($code);
         if (is_null($message)) {
             $message = 'unkown error';
         }
     }
     parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
     // Ethnaフレームワークのエラーハンドラ(PEAR_Errorのコールバックとは異なる)
     Ethna::handleError($this);
 }
Ejemplo n.º 2
0
 /**
  *  Ethna_Errorクラスのコンストラクタ
  *  $userinfo は第5引数に設定すること。
  *
  *  @access public
  *  @param  string  $message            エラーメッセージ
  *  @param  int     $code               エラーコード
  *  @param  int     $mode               エラーモード(Ethna_Errorはコールバックを
  *                                      常に使用するので実質無視される)
  *  @param  array   $options            エラーモード依存のオプション
  *  @param  array   $userinfo           エラー追加情報($options より後の全ての引数)
  *  @see http://pear.php.net/manual/ja/core.pear.pear-error.pear-error.php
  */
 public function __construct($message = null, $code = null, $mode = null, $options = null)
 {
     $container = Ethna_Container::getInstance();
     if ($container !== null) {
         $this->i18n = $container->getI18N();
     }
     // $options 以降の引数 -> $userinfo
     if (func_num_args() > 4) {
         $userinfo = array_slice(func_get_args(), 4);
         if (count($userinfo) == 1) {
             if (is_array($userinfo[0])) {
                 $this->userinfo = $userinfo[0];
             } else {
                 if (is_null($userinfo[0])) {
                     $this->userinfo = array();
                 }
             }
         } else {
             $this->userinfo = $userinfo[0];
         }
     } else {
         $this->userinfo = array();
     }
     // メッセージ補正処理 ($message)
     if (is_null($message)) {
         // $codeからメッセージを取得する
         $message = $this->getErrorMessage($code);
         if (is_null($message)) {
             $message = 'unknown error';
         }
     }
     $this->message = $message;
     //  その他メンバ変数設定
     $this->code = $code;
     $this->mode = $mode;
     $this->options = $options;
     $this->level = $this->options === NULL ? E_USER_NOTICE : $options;
     //  Ethnaフレームワークのエラーハンドラ(callback)
     Ethna::handleError($this);
 }