zend-framework,从另一个动作助手中调用动作助手

rah*_*ari 21 zend-framework

我正在写一个动作帮助器,我需要从该帮助器中调用另一个动作帮助器.但我不知道怎么做.这里是示例代码:

class Common_Controller_Action_Helper_SAMPLE extends Zend_Controller_Action_Helper_Abstract
{
    protected $_view;
    public function __construct(Zend_View_Interface $view = null, array $options = array())
    {
        $this->_view = $view;
    }

    public function preDispatch()
    {
        $flashMessenger = $this->_helper->FlashMessenger; // IT IS NULL
    }
}
Run Code Online (Sandbox Code Playgroud)

mer*_*tor 36

使用动作助手经纪人:

$flashMessenger =
    Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
Run Code Online (Sandbox Code Playgroud)


And*_*nko 11

另一种解决方案是

$flashMessenger = $this->getActionController()->getHelper('FlashMessenger');
Run Code Online (Sandbox Code Playgroud)