访问前端控制器插件中的动作助手



我试图从插件(在bootstrap中注册)调用helper的视图。从任何控制器,我能够访问没有任何问题,但不是从插件。下面是我的代码。任何帮助都是感激的。谢谢你!米格尔

class Plugins_security extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch (Zend_Controller_Request_Abstract $request)
    {
        $auth = Zend_Auth::getInstance();
        $moduleName = $request->getModuleName();
        if ($request->getModuleName() != "auth") 
        {
            $auth = Zend_Auth::getInstance();
            if (! $auth->hasIdentity()) 
            {
                $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper(
                'redirector');
                $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessages');
                $flashMessenger->flashMessenger (array('message' => 'Sessao expirada', 'status' => 'error'));
                $redirector->gotoUrl('/auth/login/')->redirectAndExit();
            }
        }
    }
} 

我得到以下错误。致命错误:未捕获的异常'Zend_Loader_PluginLoader_Exception'与消息'Plugin by name 'FlashMessages'未在注册表中找到;使用路径:Zend_Controller_Action_Helper_: Zend/Controller/Action/Helper/' in/usr/local/Zend/share/zendframework/library/Zend/Loader/PluginLoader.php:412 Stack trace: #0/usr/local/Zend/share/zendframework/library/Zend/Controller/Action/HelperBroker.php(366):

你必须改变

Zend_Controller_Action_HelperBroker: getStaticHelper (FlashMessages);

Zend_Controller_Action_HelperBroker: getStaticHelper (FlashMessenger);

的例子:$flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper(' flashMessenger ');$flashMessenger->addMessage(array('error' => 'Session expired'));

希望这对你有帮助。不是测试

相关内容

  • 没有找到相关文章

最新更新