【发布时间】:2014-11-10 10:24:02
【问题描述】:
我在 Module.php 方法 getServiceConfig() 中有 Doctrine 工厂:
public function getServiceConfig()
{
return array(
'factories' => array(
'doctrine.entitymanager.orm_cst' => new \DoctrineORMModule\Service\EntityManagerFactory('orm_cst'),
'doctrine.connection.orm_cst' => function ($sm) {
$config = $sm->get('config');
return new \DoctrineORMModule\Service\DBALConnectionFactory('doctrine.entitymanager.' . $config['connection']);
},
'doctrine.configuration.orm_cst' => new \DoctrineORMModule\Service\ConfigurationFactory('orm_cst'),
'doctrine.driver.orm_cst' => new \DoctrineModule\Service\DriverFactory('orm_cst'),
'doctrine.eventmanager.orm_cst' => new \DoctrineModule\Service\EventManagerFactory('orm_cst'),
),
);
}
我正在尝试从 config 获取连接值,但出现以下错误:
Catchable fatal error: Object of class DoctrineORMModule\Service\DBALConnectionFactory could not be converted to string in W:\domains\zf\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php on line 939
如果我不使用函数作为数组值也没关系:
'doctrine.connection.orm_cst' => new \DoctrineORMModule\Service\DBALConnectionFactory('orm_cst'),
我做错了什么?请帮忙。
【问题讨论】:
-
$config['connection']持有什么。
标签: php doctrine-orm zend-framework2