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