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


PHP EntityManager::close方法代碼示例

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


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

示例1: tearDown

 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     if ($this->em instanceof \Doctrine\ORM\EntityManager) {
         $this->em->close();
     }
 }
開發者ID:skonsoft,項目名稱:postal-address-bundle,代碼行數:10,代碼來源:WebTestCase.php

示例2: tearDown

 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     if (!is_null($this->em)) {
         $this->em->close();
     }
 }
開發者ID:aboutcoders,項目名稱:job-bundle,代碼行數:10,代碼來源:DatabaseKernelTestCase.php

示例3: tearDown

 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     $this->em->close();
     $this->em = null;
     // avoid memory leaks
 }
開發者ID:aarocax,項目名稱:style,代碼行數:10,代碼來源:ScheduleRepositoryTest.php

示例4: allBooks

 public function allBooks()
 {
     try {
         $book = $this->em->getRepository('BooksApiBookBundle:BooksEntity')->findAll();
     } catch (\Exception $ex) {
         $this->em->close();
         throw new QueryException('003', 502);
     }
     return $book;
 }
開發者ID:tomazi15,項目名稱:books-api,代碼行數:10,代碼來源:FetchAllBooksRepository.php

示例5: tearDown

 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     $this->em->close();
     //cerrar emMod
     /*$this->emMod = static::$kernel->getContainer()
           ->get('doctrine')
           ->getManager();
       $this->emMod->close();*/
 }
開發者ID:smarquina,項目名稱:misBeans,代碼行數:13,代碼來源:Entity.php

示例6: tearDownDoctrine

 /**
  * @after
  */
 protected function tearDownDoctrine()
 {
     $this->doctrine = null;
     if ($this->em) {
         $this->em->close();
         $this->em = null;
     }
     $this->loader = null;
     $this->container = null;
 }
開發者ID:jasongrimes,項目名稱:stressmonkey,代碼行數:13,代碼來源:DoctrineTraits.php

示例7: close

 /**
  * close Doctrine Dbal and ORM connection and reset everything to default.
  */
 public function close()
 {
     $this->Conn->close();
     if (is_object($this->EntityManager) && method_exists($this->EntityManager, 'close')) {
         $this->EntityManager->close();
     }
     if (function_exists('gc_collect_cycles')) {
         gc_collect_cycles();
     }
     $this->Conn = '';
     $this->EntityManager = '';
     $this->table_prefix = '';
     $this->table_siteid_prefix = '';
 }
開發者ID:AgniCMS,項目名稱:agni-framework,代碼行數:17,代碼來源:Db.php

示例8: createBook

 /**
  * @param $title
  * @param $price
  * @param $description
  * @throws QueryException
  */
 public function createBook($title, $price, $description)
 {
     $book = new BooksEntity();
     $book->setTitle($title);
     $book->setPrice($price);
     $book->setDescription($description);
     try {
         $this->em->persist($book);
         $this->em->flush();
         return true;
     } catch (\Exception $ex) {
         $this->em->close();
         throw new QueryException('003', 502);
     }
 }
開發者ID:tomazi15,項目名稱:books-api,代碼行數:21,代碼來源:CreateBookRepository.php

示例9: restartDoctrine

 public function restartDoctrine()
 {
     $enabled_filters = array();
     if (isset($this->entity_manager)) {
         $filters = $this->entity_manager->getFilters();
         foreach ($filters->getEnabledFilters() as $filter_name => $filter) {
             $filter_class = get_class($filter);
             $enabled_filters[$filter_name] = array($filter_class => $filter->__toString());
         }
         @$this->entity_manager->close();
         unset($this->entity_manager);
     }
     $em = $this->getDoctrine();
     foreach ($enabled_filters as $filter_name => $filter) {
         foreach ($filter as $filter_class => $filter_params_string) {
             $em->getConfiguration()->addFilter($filter_name, $filter_class);
             $this_filter = $em->getFilters()->enable($filter_name);
             $filter_params = @unserialize($filter_params_string);
             if ($filter_params) {
                 foreach ($filter_params as $filter_param => $filter_value) {
                     if (isset($filter_value['value'])) {
                         $this_filter->setParameter($filter_param, $filter_value['value']);
                     }
                 }
             }
         }
     }
 }
開發者ID:netshine,項目名稱:scaffold,代碼行數:28,代碼來源:Database.php

示例10: tearDown

 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     $this->em->remove($this->user);
     $this->em->close();
     //unset($this->user); //
 }
開發者ID:vegardbb,項目名稱:webpage,代碼行數:10,代碼來源:UserRepositoryFunctionalTest.php

示例11: uninstall

 /**
  * @param \Venne\Module\IModule $module
  */
 public function uninstall(IModule $module)
 {
     if (!$this->context->hasService('doctrine') || !$this->context->doctrine->createCheckConnection()) {
         throw new \Exception('Database connection not found!');
     }
     $classes = $this->getClasses($module);
     $metadata = array();
     foreach ($classes as $class) {
         $metadata[] = $this->entityManager->getClassMetadata($class);
     }
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     $this->entityManager->getConnection()->beginTransaction();
     try {
         foreach ($classes as $class) {
             $repository = $this->entityManager->getRepository($class);
             foreach ($repository->findAll() as $entity) {
                 $repository->delete($entity);
             }
         }
         $tool->dropSchema($metadata);
         $this->entityManager->getConnection()->commit();
     } catch (Exception $e) {
         $this->entityManager->getConnection()->rollback();
         $this->entityManager->close();
         throw $e;
     }
     $this->cleanCache();
 }
開發者ID:svobodni,項目名稱:web,代碼行數:31,代碼來源:DoctrineInstaller.php

示例12: close

 /**
  * {@inheritdoc}
  */
 public function close()
 {
     $evm = $this->getEventManager();
     if ($evm->hasListeners(Events::preClose)) {
         $evm->dispatchEvent(Events::preClose, new PreCloseEventArgs($this));
     }
     parent::close();
 }
開發者ID:hugeval,項目名稱:platform,代碼行數:11,代碼來源:OroEntityManager.php

示例13: tearDownAfterClass

 /**
  * {@inheritDoc}
  * 
  * @see PHPUnit_Framework_TestCase::tearDownAfterClass()
  * 
  * @uses KernelTestCase::ensureKernelShutdown()
  */
 public static function tearDownAfterClass()
 {
     parent::ensureKernelShutdown();
     static::$em->close();
     static::$em = null;
     // avoid memory leaks
     static::$repository->clear();
     static::$repository = null;
 }
開發者ID:vaxz,項目名稱:bc-genome,代碼行數:16,代碼來源:ChromosomeRepositoryTest.php

示例14: dropEntityManager

 /**
  * Drop the entity manager
  * @return void
  */
 public function dropEntityManager()
 {
     if ($this->entityManager != null) {
         $this->entityManager->getConnection()->close();
         $this->entityManager->close();
     }
     unset($this->entityManager);
     unset($this->fixtureReferenceRepo);
 }
開發者ID:51systems,項目名稱:doctrine-test,代碼行數:13,代碼來源:EntityTestCase.php

示例15: putWithdrawalAction

 /**
  * вывести деньги
  *
  * @ApiDoc(
  *     section="Billing API",
  *     input="Vifeed\PaymentBundle\Form\WithdrawalType",
  *     output={
  *          "class"="Vifeed\PaymentBundle\Entity\Withdrawal",
  *          "groups"={"default"}
  *     },
  *     resource=true,
  *     statusCodes={
  *         201="Returned when successful",
  *         400="Returned when something is wrong",
  *         403="Returned when the user is not authorized to use this method"
  *     }
  * )
  *
  * @return Response
  */
 public function putWithdrawalAction()
 {
     $form = $this->createForm(new WithdrawalType());
     $form->submit($this->get('request'));
     if ($form->isValid()) {
         /** @var Withdrawal $withdrawal */
         $withdrawal = $form->getData();
         if ($withdrawal->getWallet()->getUser() != $this->getUser()) {
             throw new AccessDeniedHttpException('Можно вывести только на свой кошелёк');
         }
         if ($withdrawal->getAmount() > $this->getUser()->getBalance()) {
             $form->get('amount')->addError(new FormError('Недостаточно денег на балансе'));
         } else {
             $userRepo = $this->em->getRepository('VifeedUserBundle:User');
             $this->em->beginTransaction();
             $this->em->lock($this->getUser(), LockMode::PESSIMISTIC_WRITE);
             try {
                 $withdrawal->setUser($this->getUser())->setStatus(Withdrawal::STATUS_CREATED);
                 $this->em->persist($withdrawal);
                 $userRepo->updateBalance($this->getUser(), -$withdrawal->getAmount());
                 $this->em->flush();
                 $this->em->commit();
             } catch (\Exception $e) {
                 $this->em->rollback();
                 $this->em->close();
                 throw $e;
             }
             $mailer = $this->get('vifeed.mailer');
             $message = $mailer->renderMessage('VifeedPaymentBundle:Email:withdrawal.html.twig', ['withdrawal' => $withdrawal]);
             $mailer->sendMessage('Запрос на вывод средств', $message, $this->container->getParameter('withdrawal.notification.email'));
             $context = new SerializationContext();
             $context->setGroups(array('default'));
             $view = new View($withdrawal, 201);
             $view->setSerializationContext($context);
         }
     }
     if (!$form->isValid()) {
         $view = new View($form, 400);
     }
     return $this->handleView($view);
 }
開發者ID:bzis,項目名稱:zomba,代碼行數:61,代碼來源:WithdrawalController.php


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