Source for file Plugin.php
Documentation is available at Plugin.php
// vim: foldmethod=marker
* @author ICHII Takashi <ichii386@schweetheart.jp>
* @author Kazuhiro Hosoi <hosoi@gree.co.jp>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @version $Id: dfb2c925eed3ab9e28c1135fa97ee80b9fc4c4d7 $
* @author ICHII Takashi <ichii386@schweetheart.jp>
* @author Kazuhiro Hosoi <hosoi@gree.co.jp>
/** @protected object Ethna_Controller コントローラオブジェクト */
/** @protected object Ethna_Controller コントローラオブジェクト($controllerの省略形) */
/** @protected object Ethna_Logger ログオブジェクト */
/** @public array プラグインのオブジェクト(インスタンス)を保存する配列 */
/** @protected array プラグインのクラス名、ソースファイル名を保存する配列 */
/** @protected array 検索対象ディレクトリを,プラグインの優先順に保存する配列 */
* @param object Ethna_Controller $controller コントローラオブジェクト
$this->_loadPluginDirList();
* LogWriterはpluginなので、pluginインスタンス作成時点では
* @param object Ethna_Logger $logger ログオブジェクト
* @param string $type プラグインの種類
* @param string $name プラグインの名前
* @return object プラグインのインスタンス
return $this->_getPlugin($type, $name);
* ある種類 ($type) のプラグイン ($name) の全リストを取得
* @param string $type プラグインの種類
* @return array プラグインオブジェクトの配列
$plugin_list[$name] =
$this->getPlugin($type, $name);
// {{{ obj_registry のアクセサ
* @param string $type プラグインの種類
* @param string $name プラグインの名前
* @return object プラグインのインスタンス
private function _getPlugin($type, $name)
// プラグインの親クラスを(存在すれば)読み込み
$this->_includePluginSrc($class, $dir, $file, true);
$this->_loadPlugin($type, $name);
* get plugin obejct and set to property
* @param string $plugin_alias_name property name to set
* @param array $plugin array(type, name)
public function setPlugin($plugin_alias_name, $plugin)
if (isset
($this->{$plugin_alias_name})) {
return Ethna::raiseWarning('preload plugin alias name is conflicted [alias=%s], It doesn\'t loaded.',
E_PLUGIN_GENERAL, $plugin_alias_name);
$this->{$plugin_alias_name} =
$this->getPlugin($plugin[0], $plugin[1]);
* プラグインをincludeしてnewし,レジストリに登録
* @param string $type プラグインの種類
* @param string $name プラグインの名前
private function _loadPlugin($type, $name)
$plugin_src_registry =
$this->_getPluginSrc($type, $name);
if (is_null($plugin_src_registry)) {
list
($plugin_class, $plugin_dir, $plugin_file) =
$plugin_src_registry;
$r =
$this->_includePluginSrc($plugin_class, $plugin_dir, $plugin_file);
$instance =
new $plugin_class($this->controller, $type, $name);
$this->logger->log(LOG_WARNING, 'plugin [%s::%s] instantiation failed', $type, $name);
* @param string $type プラグインの種類
* @param string $name プラグインの名前
* @param string $type プラグインの種類
* @param string $name プラグインの名前
private function _loadPluginDirList()
// Communiy based libraries
foreach ($include_path_list as $include_path) {
// {{{ src_registry のアクセサ
* プラグインのソースファイル名とクラス名をレジストリから取得
* @param string $type プラグインの種類
* @param string $name プラグインの名前
* @return array ソースファイル名とクラス名からなる配列
private function _getPluginSrc($type, $name)
$this->_searchPluginSrc($type, $name);
* プラグインのクラス名、ディレクトリ、ファイル名を決定
* @param string $type プラグインの種類
* @param string $name プラグインの名前 (nullのときは親クラス)
* @param string $appid アプリケーションID (廃止予定)
* @return array プラグインのクラス名、ファイル名の配列
$ext =
$this->ctl->getExt('php');
$plugin_class_name =
array(
$plugin_class_name[] =
$name;
$class =
implode('_', $plugin_class_name);
$file =
"{
$name}.{$ext}";
return array($class, $file);
* @param string $class クラス名
* @param string $dir ディレクトリ名
* @param string $file ファイル名
* @param bool $parent 親クラスかどうかのフラグ
* @return true|Ethna_Error
private function _includePluginSrc($class, $dir, $file, $parent =
false)
$file =
$dir .
'/' .
$file;
$this->logger->log(LOG_DEBUG, 'plugin class [%s] is defined', $class);
* @param string $type プラグインの種類
* @param string $name プラグインの名前 (nullのときは親クラス)
* @retur string directory
* アプリケーション, extlib, Ethna の順でプラグインのソースを検索する
* @param string $type プラグインの種類
* @param string $name プラグインの名前
* @return array class, dir, file
private function _searchPluginSrc($type, $name)
// 古いバージョンのプラグインの命名規則にしたがったファイルは無視
if (strpos($name, "_") !==
false) {
$this->logger->log(LOG_DEBUG, 'plugin file is found in search: [%s/%s]',
$this->src_registry[$type][$name] =
array($class, $dir, $file);
// 見つからなかった場合 (nullで記憶しておく)
$this->logger->log(LOG_WARNING, 'plugin file for [type=%s, name=%s] is not found in search', $type, $name);
* プラグインの種類 ($type) をすべて検索する
foreach ($type_dir as $dir) {
if ($type_dir{0} !=
'.') {
* 指定された $type のプラグイン (のソース) をすべて検索する
* @param string $type プラグインの種類
// 後で見付かったもので上書きするので $this->appid_list の逆順とする
$ext =
$this->ctl->getExt('php');
$this->logger->log(LOG_DEBUG, 'cannot open plugin directory: [%s/%s]', $dir, $type);
$this->logger->log(LOG_DEBUG, 'plugin directory opened: [%s]', $dir);
foreach ($files as $plugin_file) {
$name_list[$plugin_name] =
0;
$this->_searchPluginSrc($type, $name);
// {{{ static な include メソッド
* Ethna 本体付属のプラグインのソースを include する
* (B.C.) Ethna 2.5.0 perview 5 以降,このメソッドには意味がありません.Ethna_Plugin::import を使ってください
* @param string $type プラグインの種類
* @param string $name プラグインの名前
* @param string $type プラグインの種類
* @param string $name プラグインの名前
$this->_includePluginSrc($class, $dir, $file);
$this->_includePluginSrc($class, $dir, $file);
* @param string $type プラグインの種類
* @param string $name プラグインの名前
// static function import($type, $name = null)
public static function import($type, $name =
null)
Documentation generated on Fri, 11 Nov 2011 03:58:57 +0900 by phpDocumentor 1.4.3