如何在Zend Framework中取消注册控制器插件

时间:2012-09-06 13:48:20

标签: zend-framework

如何从控制器操作中取消注册或禁用控制器插件。

class IndexController
{
    public function indexAction()
    {
        // disable plugin here
        // do some other stuff
    }
}

1 个答案:

答案 0 :(得分:2)

首先获取前端控制器的实例,然后获取给定名称(类名称)的插件实例,最后调用unregisterPlugin()方法。

public function disableSomePluign()
{
    $frontController = $this->getFrontController();
    $plugin = $frontController->getPlugin('Some_Plugin');
    $frontController->unregisterPlugin($plugin);
}