2

我创建了自定义应用程序资源:

class Custom_Entitymanager extends Zend_Application_Resource_ResourceAbstract{
    //...
    public function init (){
        //...
        $em = \Doctrine\ORM\EntityManager::create($options['connection'],  $config);
        return $em;
    }
}

我把它放在MyProject\library\Custom\Entitymanager.php文件中。

当我想使用检索时Entitymanager

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

我得到空对象。

如何在application.ini文件中注册我的自定义应用程序资源?

4

1 回答 1

7

application/configs/application.ini

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

旁注:我可能会将 EntityManager 类更深入地推入我自己的自定义库中,可能类似于Custom_Application_Resource_EntityManager. 在这种情况下,上面的路径映射将更改为:

pluginpaths.Custom_Application_Resource_ =  APPLICATION_PATH "/../library/Custom/Application/Resource"
resources.EntityManager[] =
于 2011-07-24T12:14:37.423 回答