本文整理匯總了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;
}