How to add a third-party Action Helper to a Zend Framework 1.8+ application?

本小妞迷上赌 提交于 2019-12-11 16:59:05

问题


I have downloaded a third party action helper that I would like to add to my application. How can I do this?


回答1:


Using the Noginn SendFile Action Helper as a reference, dropped into the library directory, the directory structure looks like this:

/library
    /Noginn
        /Controller
            /Action
                /Helper
                    /SendFile.php

In /application/Bootstrap.php add an init function and add the class prefix:

protected function _initActionHelpers()
{
    Zend_Controller_Action_HelperBroker::addPrefix('Noginn_Controller_Action_Helper');
}

Then in your controller, you can call the action helper like this:

$this->_helper->sendFile($options);



回答2:


Another solution is to add it in straight forward manner:

Zend_Controller_Action_HelperBroker::addHelper(new Wow_Controller_Action_Helper_Auth());

You can also add to helper broker prefix, as Andrew did, or add path to your new helpers. All these options are well explained the manual.




回答3:


This should help: The Helper Broker

Zend_Controller_Action_HelperBroker::addHelper(new Your_Controller_Action_Helper());

Just make sure that Your_Controller_Action_Helper is auto-loadable, or is included.



来源:https://stackoverflow.com/questions/1910391/how-to-add-a-third-party-action-helper-to-a-zend-framework-1-8-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!