当前位置: 首页>>代码示例>>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;未经允许,请勿转载。