开发者

How to register custom application resources in application.ini in Zend Framework 1.11.x

开发者 https://www.devze.com 2023-03-22 18:19 出处:网络
I have created custom aplication resource: class Custom_Entitymanager extends Zend_Application_Resource_ResourceAbstract{

I have created custom aplication resource:

class Custom_Entitymanager extends Zend_Application_Resource_ResourceAbstract{
    //...
    public function init (){
        //...
        $em = \Doctrine\ORM\EntityManager::create($optio开发者_Python百科ns['connection'],  $config);
        return $em;
    }
}

and I put it in MyProject\library\Custom\Entitymanager.php file.

When I want to retrieve Entitymanager using:

$em = $this->getInvokeArg('bootstrap')->getResource('entityManager');

I get null object.

How can I register my custom application resource in application.ini file?


In application/configs/application.ini:

pluginpaths.Custom_ =  APPLICATION_PATH "/../library/Custom"
resources.EntityManager[] =

Side note: I'd probably push the EntityManager class down a little deeper into my own custom library, perhaps something like Custom_Application_Resource_EntityManager. In this case, the path mapping above would change to:

pluginpaths.Custom_Application_Resource_ =  APPLICATION_PATH "/../library/Custom/Application/Resource"
resources.EntityManager[] =
0

精彩评论

暂无评论...
验证码 换一张
取 消