本文整理汇总了PHP中Seitenbau\Registry::setEntityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::setEntityManager方法的具体用法?PHP Registry::setEntityManager怎么用?PHP Registry::setEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Seitenbau\Registry
的用法示例。
在下文中一共展示了Registry::setEntityManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initDoctrine
protected function _initDoctrine()
{
$appDoctrineConfig = $this->getOption('doctrine');
$classLoader = new DoctrineClassLoader('Doctrine');
$classLoader->setIncludePath(realpath(APPLICATION_PATH . '/../library'));
$classLoader->register();
$config = new DoctrineConfiguration();
if (isset($appDoctrineConfig['cache'])) {
switch ($appDoctrineConfig['cache']) {
case 'array':
$cache = new DoctrineArrayCache();
break;
case 'apc':
$cache = new DoctrineApcCache();
break;
}
$config->setQueryCacheImpl($cache);
$config->setMetadataCacheImpl($cache);
}
$proxyDir = empty($appDoctrineConfig['proxyDir']) ? APPLICATION_PATH . '/../library/Orm/Proxies' : $appDoctrineConfig['proxyDir'];
$config->setProxyDir(realpath($proxyDir));
$config->setProxyNamespace('Orm\\Proxies');
$config->setAutoGenerateProxyClasses(false);
$config->setEntityNamespaces(array('Orm\\Entity'));
$config->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\StaticPHPDriver(realpath(APPLICATION_PATH . '/../library/Orm/Entity')));
//$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
$config->setSQLLogger(null);
$db = $this->getResource('db');
$dbConfig = $db->getConfig();
$connectionOptions = array('pdo' => $db->getConnection(), 'dbname' => $dbConfig['dbname']);
$entityManager = DoctrineEntityManager::create($connectionOptions, $config);
$entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
Registry::setEntityManager($entityManager);
return $entityManager;
}