Zend Framework Bootstrap Issue

若如初见. 提交于 2019-12-04 14:12:16

You're not using the helper broker correctly. addPrefix() is used to add pluginloader prefix paths, not actual classes.

If you want to add concrete helpers (to use their dispatch hooks presumably), then place something like this in your Bootstrap class

protected function _initActionHelpers()
{
    $helper = new My_Helper;
    Zend_Controller_Action_HelperBroker::addHelper($helper);
}

For regular, runtime helpers, you can easily add prefix paths in your config, eg

resources.frontController.actionHelperPaths.ProEquipTrack_Controller_Action_Helper = "ProEquipTrack/Controller/Action/Helper"

These will be automatically loaded by the broker at call time, eg (controller context)

$resourceInjector = $this->getHelper('ResourceInjector');
$em = $this->getHelper('Em');

or using the strategy pattern (direct() method)

$this->_helper->resourceInjector($arg1, $arg2 /*, etc */);

Doctrine Entity Manager

Do something like this in your Bootstrap class

protected function _initDoctrine()
{
    // initialise and create entity manager
    $em = // whatever

    return $em;
}

You can now access the entity manager in your controllers using this

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