コード例 #1
0
 /**
  *  プラグインをセットする
  * 
  *  @param string $name プラグイン名
  *  @param string $type プラグインタイプ
  *  @param mixed $plugin プラグイン本体
  * 
  *  @access public
  */
 function setPlugin($name, $type, $plugin)
 {
     //プラグイン関数の有無をチェック
     if (is_callable($plugin) === false) {
         return Ethna::raiseWarning('Does not exists.');
     }
     //プラグインの種類をチェック
     $register_method = 'register_' . $type;
     if (method_exists($this->engine, $register_method) === false) {
         return Ethna::raiseWarning('This plugin type does not exist');
     }
     // フィルタは名前なしで登録
     if ($type === 'prefilter' || $type === 'postfilter' || $type === 'outputfilter') {
         parent::setPlugin($name, $type, $plugin);
         $this->engine->{$register_method}($plugin);
         return;
     }
     // プラグインの名前をチェック
     if ($name === '') {
         return Ethna::raiseWarning('Please set plugin name');
     }
     // プラグインを登録する
     parent::setPlugin($name, $type, $plugin);
     $this->engine->{$register_method}($name, $plugin);
 }