本文整理汇总了PHP中Kdyby\Doctrine\EntityManager::isOpen方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::isOpen方法的具体用法?PHP EntityManager::isOpen怎么用?PHP EntityManager::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kdyby\Doctrine\EntityManager
的用法示例。
在下文中一共展示了EntityManager::isOpen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Consumer callback
*
* @param AMQPMessage $msg
*/
public function process(AMQPMessage $msg)
{
if (!$this->em->isOpen()) {
// Entity manager is not open, so terminate
throw new TerminateException();
}
try {
$this->em->clear();
} catch (\Exception $e) {
// Cannot clear entity manager, so terminate
throw new TerminateException();
}
try {
// Try to process the message
$flag = $this->processMessage($msg);
} catch (\Exception $e) {
// Stop consuming, because some unhandeled exception during message process occured.
throw new TerminateException();
}
if ($this->oneRunOnly) {
throw (new TerminateException())->withResponse($flag);
} else {
return $flag;
}
}
示例2: restartJob
/**
* @throws TerminateException
*/
protected function restartJob(array $request, \Exception $exception = null, $message = null) : int
{
$this->logger->addError(sprintf('job requeue(%s) for order %d because of %s: %s', $request['retryCounter'], $request['orderId'], get_class($exception), $message ?: $exception->getMessage()));
$this->append($this->em->getReference(Order::class, $request['orderId']), $request['retryCounter'] + 1, $request['options']);
if (!$this->em->isOpen()) {
sleep(self::DELAY_ON_RESTART);
throw TerminateException::withResponse(self::MSG_REJECT);
}
return self::MSG_REJECT;
}