YafUse icon indicating copy to clipboard operation
YafUse copied to clipboard

在哪里注册的LayoutPlugin?

Open zikezhang opened this issue 10 years ago • 2 comments

你好,我没找到注册LayoutPlugin的地方,按照常例是应该在Boostrap里面添加:

    public function _initPlugin(Yaf_Dispatcher $dispatcher) {
         $layoutplugin = new LayoutPlugin ();
         $dispatcher->registerPlugin($layoutplugin );
 }

请教你问一下:你用了其他的什么方法注册Plugin的吗?谢谢.

zikezhang avatar Jan 17 '15 20:01 zikezhang

我没有进行统一注册LayoutPlugin,因为考虑到了项目中可能会使用很多不同的页面布局。如果是项目中是统一的,那就最好是在Bootstrap中注册,我是具体写在了控制器中。例:Admin.php 中是这样使用的

public function init() {
    parent::init();
    //使用layout页面布局
    $this->_layout = new LayoutPlugin('layout.html');
    $this->dispatcher = Yaf_Registry::get("dispatcher");
    $this->dispatcher->registerPlugin($this->_layout);
}

melonwool avatar Jan 19 '15 03:01 melonwool

懂了,谢谢!

zikezhang avatar Jan 19 '15 20:01 zikezhang