本文整理匯總了PHP中Doctrine\Bundle\DoctrineBundle\Registry::resetEntityManager方法的典型用法代碼示例。如果您正苦於以下問題:PHP Registry::resetEntityManager方法的具體用法?PHP Registry::resetEntityManager怎麽用?PHP Registry::resetEntityManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Bundle\DoctrineBundle\Registry
的用法示例。
在下文中一共展示了Registry::resetEntityManager方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: logException
/**
* TODO: copied this to ErrorLogService; use that instead
*
* @param \Exception $exception
*/
public function logException(\Exception $exception)
{
$errorLog = new ErrorLog();
$errorLog->setErrorType(ErrorType::EXCEPTION);
$errorLog->setMessage($exception->getMessage());
$errorLog->setStacktrace($exception->getTraceAsString());
$errorLog->setHttpUserAgent(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
$errorLog->setRemoteAddress(isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '');
$errorLog->setServerJSON(\json_encode($_SERVER));
$em = $this->doctrine->getEntityManager('logger');
if (!$em->isOpen()) {
$this->doctrine->resetEntityManager('logger');
$em = $this->doctrine->getEntityManager('logger');
}
$em->persist($errorLog);
$em->flush();
// save log
}
示例2: testResetUnknownEntityManager
public function testResetUnknownEntityManager()
{
$container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$registry = new Registry($container, array(), array(), 'default', 'default');
$this->setExpectedException('InvalidArgumentException', 'Doctrine ORM Manager named "default" does not exist.');
$registry->resetEntityManager('default');
}