PHP 5.6.25 + Smarty 3.1.30で開発しており、Smartyで独自プラグインを作成し使用したいのですが、どうしてもrequireしてくれません。
lang
1$this->setEngine(new Smarty()); 2$this->getEngine()->compile_dir = TOP_DIR_NAME."/template_c/"; 3$this->getEngine()->config_dir = TOP_DIR_NAME."/template_configs/"; 4$this->getEngine()->cache_dir = TOP_DIR_NAME."/template_cache/"; 5$this->getEngine()->addPluginsDir(TOP_DIR_NAME.'/SmartyCustomPlugins/');
上記の通りPluginディレクトはaddPluginsDir()メッソッドで絶対パスで追加してあります。
悩んだ挙句、smartyのspl_autoload_registerを読んでみるとautoload関数内では、どうみてもsmarty::plugins_dirを参照している気配がないのですがバグでしょうか...?
それと、クラス名を小文字に変換してファイル名を特定している部分もマニュアルに記載が無いようですが仕様ですか?
/common_libs/Smarty/libs/Autoloader.php
lang
1/** 2 * Handles auto loading of classes. 3 * 4 * @param string $class A class name. 5 */ 6public static function autoload($class) 7{ 8 var_dump($class); 9 $_class = strtolower($class); 10 if (strpos($_class, 'smarty') !== 0) { 11 return; 12 } 13 $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; 14 if (is_file($file)) { 15 include $file; 16 } else if (isset(self::$rootClasses[ $_class ])) { 17 $file = self::$SMARTY_DIR . self::$rootClasses[ $_class ]; 18 if (is_file($file)) { 19 include $file; 20 } 21 } 22 return; 23}
ちなみにspl_autoload_registerはフレームワーク側でも使用しており多段になってますが、smartyのautoloadも追加され動作している様です。(xdebugのtraceで確認済み)
独自プラグイン関数を使用しない場合Smartyは正常に機能している様です。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。