當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RegistryInterface::resetManager方法代碼示例

本文整理匯總了PHP中Symfony\Bridge\Doctrine\RegistryInterface::resetManager方法的典型用法代碼示例。如果您正苦於以下問題:PHP RegistryInterface::resetManager方法的具體用法?PHP RegistryInterface::resetManager怎麽用?PHP RegistryInterface::resetManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Bridge\Doctrine\RegistryInterface的用法示例。


在下文中一共展示了RegistryInterface::resetManager方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ensureEntityManagerReady

 /**
  * Prepares EntityManager, reset it if closed with error
  */
 protected function ensureEntityManagerReady()
 {
     $this->em = $this->registry->getManager();
     if (!$this->em->isOpen()) {
         $this->registry->resetManager();
         $this->ensureEntityManagerReady();
     }
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:11,代碼來源:PersistentBatchWriter.php

示例2: rollback

 /**
  * Closes the entity manager, and rollbacks the pending transaction on the underlying database connection of a
  * Doctrine's entity manager with the given name. This method also resets the manager, so as it can be recreated for
  * a new transaction, when needed.
  */
 protected function rollback()
 {
     $this->logger->debug(static::class . '::rollback');
     $this->getEntityManager()->rollback();
     // Close the manager if there is no transaction started.
     if (!$this->getEntityManager()->getConnection()->isTransactionActive()) {
         $this->getEntityManager()->close();
         $this->entityManagerRegistry->resetManager();
     }
 }
開發者ID:Inneair,項目名稱:transaction-bundle,代碼行數:15,代碼來源:TransactionalInterceptor.php

示例3: write

 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     /** @var EntityManager $em */
     $em = $this->registry->getManager();
     try {
         $em->beginTransaction();
         foreach ($items as $item) {
             $em->persist($item);
         }
         $em->flush();
         $em->commit();
         $configuration = $this->contextRegistry->getByStepExecution($this->stepExecution)->getConfiguration();
         $contextSkipClear = $this->stepExecution->getJobExecution()->getExecutionContext()->get(EntityWriter::SKIP_CLEAR);
         if (empty($configuration[EntityWriter::SKIP_CLEAR]) && !$contextSkipClear) {
             $em->clear();
         }
     } catch (\Exception $exception) {
         $em->rollback();
         if (!$em->isOpen()) {
             $this->registry->resetManager();
         }
         $jobName = $this->stepExecution->getJobExecution()->getJobInstance()->getAlias();
         $event = new WriterErrorEvent($items, $jobName, $exception);
         $this->eventDispatcher->dispatch(WriterErrorEvent::NAME, $event);
         if ($event->getCouldBeSkipped()) {
             $importContext = $this->contextRegistry->getByStepExecution($this->stepExecution);
             $importContext->setValue('error_entries_count', (int) $importContext->getValue('error_entries_count') + count($items));
             $this->logger->warning($event->getWarning());
             if ($event->getException() === $exception) {
                 // exception are already handled and job can move forward
                 throw new InvalidItemException($event->getWarning(), []);
             } else {
                 // exception are already created and ready to be rethrown
                 throw $event->getException();
             }
         } else {
             throw $exception;
         }
     }
     $this->eventDispatcher->dispatch(WriterAfterFlushEvent::NAME, new WriterAfterFlushEvent($em));
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:44,代碼來源:PersistentBatchWriter.php


注:本文中的Symfony\Bridge\Doctrine\RegistryInterface::resetManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。