BcBaserHelper::_initPluginBasers PHP Method

_initPluginBasers() protected method

BcBaserHelperに定義されていないメソッドをプラグイン内のヘルパに定義する事で BcBaserHelperから呼び出せるようになる仕組みを提供する。 プラグインのヘルパメソッドを BcBaserHelper 経由で直接呼び出せる為、 コア側のコントローラーでいちいちヘルパの定義をしなくてよくなり、 プラグインを導入するだけでテンプレート上でプラグインのメソッドが呼び出せるようになる。 例えば固定ページ機能のWYSIWYG内にプラグインのメソッドを書き込む事ができる。 《PluginBaserHelper の命名規則》 {プラグイン名}BaserHelper 《利用例》 - Feedプラグインに FeedBaserHelper::feed() が定義されている場合 $this->BcBaser->feed(1);
protected _initPluginBasers ( ) : void
return void
    protected function _initPluginBasers()
    {
        $view = $this->_View;
        $plugins = Configure::read('BcStatus.enablePlugins');
        if (!$plugins) {
            return;
        }
        $pluginBasers = array();
        foreach ($plugins as $plugin) {
            $pluginName = Inflector::camelize($plugin);
            if (App::import('Helper', $pluginName . '.' . $pluginName . 'Baser')) {
                $pluginBasers[] = $pluginName . 'BaserHelper';
            }
        }
        foreach ($pluginBasers as $key => $pluginBaser) {
            $this->_pluginBasers[$key] = new $pluginBaser($view);
            $this->_pluginBasers[$key]->request = $view->request;
        }
    }