本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::isOpen方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::isOpen方法的具体用法?PHP ObjectManager::isOpen怎么用?PHP ObjectManager::isOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::isOpen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: persistAll
/**
* Commits new objects and changes to objects in the current persistence
* session into the backend
*
* @param boolean $onlyWhitelistedObjects If TRUE an exception will be thrown if there are scheduled updates/deletes or insertions for objects that are not "whitelisted" (see AbstractPersistenceManager::whitelistObject())
* @return void
* @api
*/
public function persistAll($onlyWhitelistedObjects = false)
{
if ($onlyWhitelistedObjects) {
$unitOfWork = $this->entityManager->getUnitOfWork();
/** @var \Doctrine\ORM\UnitOfWork $unitOfWork */
$unitOfWork->computeChangeSets();
$objectsToBePersisted = $unitOfWork->getScheduledEntityUpdates() + $unitOfWork->getScheduledEntityDeletions() + $unitOfWork->getScheduledEntityInsertions();
foreach ($objectsToBePersisted as $object) {
$this->throwExceptionIfObjectIsNotWhitelisted($object);
}
}
if (!$this->entityManager->isOpen()) {
$this->systemLogger->log('persistAll() skipped flushing data, the Doctrine EntityManager is closed. Check the logs for error message.', LOG_ERR);
return;
}
try {
$this->entityManager->flush();
} catch (Exception $exception) {
$this->systemLogger->logException($exception);
/** @var Connection $connection */
$connection = $this->entityManager->getConnection();
$connection->close();
$connection->connect();
$this->systemLogger->log('Reconnected the Doctrine EntityManager to the persistence backend.', LOG_INFO);
$this->entityManager->flush();
} finally {
$this->emitAllObjectsPersisted();
}
}
示例2: persistAll
/**
* Commits new objects and changes to objects in the current persistence
* session into the backend
*
* @return void
* @api
*/
public function persistAll()
{
if ($this->entityManager->isOpen()) {
$this->entityManager->flush();
$this->emitAllObjectsPersisted();
} else {
$this->systemLogger->log('persistAll() skipped flushing data, the Doctrine EntityManager is closed. Check the logs for error message.', LOG_ERR);
}
}
示例3: getObjectManager
/**
* Return a Doctrine ObjectManager
*
* @return ObjectManager
*/
public function getObjectManager()
{
// Check if Object Manager is open
// If it's closed, usually this means there has been an error
if ($this->objectManager === null || method_exists($this->objectManager, 'isOpen') && !$this->objectManager->isOpen()) {
// We want to recover and create a new instance of the Document manager
$this->setObjectManager($this->getObjectManagerFromFactory());
// But we should also create an error in the log
// @TODO Log Object Manager was closed error
}
return $this->objectManager;
}
示例4: persistAll
/**
* Commits new objects and changes to objects in the current persistence
* session into the backend
*
* @param boolean $onlyWhitelistedObjects
* @return void
* @api
*/
public function persistAll($onlyWhitelistedObjects = FALSE)
{
if ($onlyWhitelistedObjects) {
$unitOfWork = $this->entityManager->getUnitOfWork();
/** @var \Doctrine\ORM\UnitOfWork $unitOfWork */
$objectsToBePersisted = $unitOfWork->getScheduledEntityUpdates() + $unitOfWork->getScheduledEntityDeletions() + $unitOfWork->getScheduledEntityInsertions();
foreach ($objectsToBePersisted as $object) {
$this->throwExceptionIfObjectIsNotWhitelisted($object);
}
}
if ($this->entityManager->isOpen()) {
$this->entityManager->flush();
$this->emitAllObjectsPersisted();
} else {
$this->systemLogger->log('persistAll() skipped flushing data, the Doctrine EntityManager is closed. Check the logs for error message.', LOG_ERR);
}
}