本文整理匯總了PHP中Doctrine\Bundle\DoctrineBundle\Registry::resetManager方法的典型用法代碼示例。如果您正苦於以下問題:PHP Registry::resetManager方法的具體用法?PHP Registry::resetManager怎麽用?PHP Registry::resetManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Bundle\DoctrineBundle\Registry
的用法示例。
在下文中一共展示了Registry::resetManager方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
public function update(Worker $worker)
{
/** @var EntityManager $em */
$em = $this->doctrine->getManager();
$exception = null;
$i = 0;
while ($i < 5) {
try {
$worker = $this->getWorker(['queue' => $worker->getQueue(), 'instance' => $worker->getInstance(), 'host' => $worker->getHost()]);
$em->persist($worker);
$em->flush();
return;
} catch (\Exception $e) {
// the connection might have "gone away"
$this->logger->warning("Error while updating worker entity", ['message' => $e->getMessage()]);
$exception = $e;
$this->doctrine->resetManager();
$em = $this->doctrine->getManager();
$em->getConnection()->close();
$em->getConnection()->connect();
}
$i++;
}
throw new ApplicationException("Unable to update worker entity", $exception);
}
示例2: reset
private function reset()
{
if ($this->doctrine) {
/** @var Connection $c */
$c = $this->doctrine->getConnection();
$c->close();
$this->doctrine->resetManager();
}
}
示例3: 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->resetManager('default');
}