我创建了自定义应用程序资源:
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
文件中注册自定义应用程序资源?
最佳答案
在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[] =
关于zend-framework - 如何在 Zend Framework 1.11.x 中的 application.ini 中注册自定义应用程序资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6806451/