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


PHP EntityManager::clear方法代碼示例

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


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

示例1: apply

 /**
  * @param float $discount
  */
 public function apply($discount)
 {
     $this->entityManager->transactional(function () use($discount) {
         foreach ($this->items->findAll() as $item) {
             $item->applyDiscount($discount);
         }
     });
     $this->entityManager->clear();
 }
開發者ID:lzakrzewski,項目名稱:tests-with-database-examples,代碼行數:12,代碼來源:ApplyDiscountUseCase.php

示例2: finishBatch

 /**
  * Finish processed batch
  */
 protected function finishBatch()
 {
     $this->entityManager->flush();
     if ($this->entityManager->getConnection()->getTransactionNestingLevel() == 1) {
         $this->entityManager->clear();
     }
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:10,代碼來源:DeleteMassActionHandler.php

示例3: getWeaponsInfo

 private function getWeaponsInfo()
 {
     $parameters = array('iDisplayStart' => 0, 'iDisplayLenght' => 50, 'type' => 1);
     $response = file_get_contents($this->url . '?' . http_build_query($parameters));
     $response = json_decode($response, true);
     $data = $response['aaData'];
     $formattedData = array();
     //Formatting Data
     foreach ($data as $value) {
         $index = $value[0]['name'] . $value[0]['requiredLevel'];
         $formattedData[$index] = array('name' => $value[0]['name'], 'description' => $value[0]['description'], 'level' => $value[0]['requiredLevel']);
     }
     $i = 0;
     foreach ($formattedData as $value) {
         $i++;
         $item = new Item();
         $item->setName($value['name']);
         $item->setDescription($value['description']);
         $item->setLevel($value['level']);
         $item->setType('weapon');
         $this->em->persist($item);
         if ($i % 20 === 0) {
             $this->em->flush();
             $this->em->clear();
         }
     }
     $this->em->flush();
     $this->em->clear();
 }
開發者ID:andregavazzoni,項目名稱:eso,代碼行數:29,代碼來源:CrawlerEsoHeadCommand.php

示例4: tearDown

 protected function tearDown()
 {
     // Clean anything still idle in the UOW
     $this->_em->clear();
     // Clear out anything set in the db (schema is recreated on setUp()
     $this->_schemaTool->dropDatabase();
 }
開發者ID:jdrich,項目名稱:drest,代碼行數:7,代碼來源:DrestFunctionalTestCase.php

示例5: setupTestSchema

 private function setupTestSchema()
 {
     $this->entityManager->clear();
     $classes = $this->entityManager->getMetaDataFactory()->getAllMetaData();
     $tool = new Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     // $tool->dropSchema($classes);
     $tool->createSchema($classes);
 }
開發者ID:pdt256,項目名稱:truecar,代碼行數:8,代碼來源:DoctrineTestCase.php

示例6: write

 /**
  * Do persist into EntityManager
  *
  * @param array $items
  */
 private function write(array $items)
 {
     foreach ($items as $item) {
         $this->em->persist($item);
     }
     $this->em->flush();
     $this->em->clear();
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:13,代碼來源:DatabasePersister.php

示例7: tearDown

 /**
  * Sweeps the database tables and clears the EntityManager.
  *
  * @return void
  */
 protected function tearDown()
 {
     if (null === static::$_conn) {
         return;
     }
     if (null !== static::$_em) {
         static::$_em->clear();
     }
 }
開發者ID:ekyna,項目名稱:commerce,代碼行數:14,代碼來源:DatabaseTestCase.php

示例8: write

 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     foreach ($items as $item) {
         $this->entityManager->persist($item);
         $this->detachFixer->fixEntityAssociationFields($item, 1);
     }
     $this->entityManager->flush();
     $this->entityManager->clear();
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:12,代碼來源:EntityWriter.php

示例9: clean

 protected function clean()
 {
     $em = self::$em;
     $reflectedEm = new \ReflectionClass($em);
     if ($reflectedEm->hasProperty('repositories')) {
         $property = $reflectedEm->getProperty('repositories');
         $property->setAccessible(true);
         $property->setValue($em, array());
     }
     self::$em->clear();
 }
開發者ID:lenninsanchez,項目名稱:donadores,代碼行數:11,代碼來源:Doctrine2.php

示例10: write

 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     foreach ($items as $item) {
         $this->entityManager->persist($item);
         $this->detachFixer->fixEntityAssociationFields($item, 1);
     }
     $this->entityManager->flush();
     $configuration = $this->contextRegistry->getByStepExecution($this->stepExecution)->getConfiguration();
     if (empty($configuration[self::SKIP_CLEAR])) {
         $this->entityManager->clear();
     }
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:15,代碼來源:EntityWriter.php

示例11: should_add_new_user

 /** @test */
 public function should_add_new_user()
 {
     $userStub = UserStub::create();
     $user = $this->repository->add($userStub);
     $this->em->clear();
     $user = $this->repository->userOfEmail($userStub->email());
     $this->assertEquals($userStub->id(), $user->id());
     $this->assertEquals($userStub->email(), $user->email());
     $this->assertEquals($userStub->username(), $user->username());
     $this->assertEquals($userStub->firstName(), $user->firstName());
     $this->assertEquals($userStub->lastName(), $user->lastName());
 }
開發者ID:Evyy,項目名稱:cffs-api,代碼行數:13,代碼來源:DoctrineUserRepositoryTest.php

示例12: setUp

 protected function setUp()
 {
     $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/../Entity/'], true, null, null, false);
     $this->manager = EntityManager::create(['driver' => 'pdo_sqlite', 'memory' => true], $config);
     (new SchemaTool($this->manager))->createSchema($this->manager->getMetadataFactory()->getAllMetadata());
     $this->manager->persist(new Person('john', 'John', 11, null));
     $this->manager->persist(new Person('jane', 'Jane', 21, 'jane@magento.com'));
     $this->manager->persist(new Person('joey', 'Joey', 31, ''));
     $this->manager->flush();
     $this->manager->clear();
     $this->transformer = SQLTransformerBuilder::make()->build();
 }
開發者ID:skolodyazhnyy,項目名稱:query-language,代碼行數:12,代碼來源:SQLTransformerDoctrineTest.php

示例13: getConnection

 protected function getConnection()
 {
     if (is_null($this->app)) {
         $this->app = $this->getApplication();
     }
     $this->em = EntityManagerFactory::initializeTestEntityManager($this->app);
     $pdo = $this->em->getConnection()->getWrappedConnection();
     $this->em->clear();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $classes = $this->em->getMetadataFactory()->getAllMetadata();
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
     return $this->createDefaultDBConnection($pdo, 'fcms_test');
 }
開發者ID:francescocambi,項目名稱:FCMS2,代碼行數:14,代碼來源:SilexAppTestCase.php

示例14: testTransformedValueIsStored

 public function testTransformedValueIsStored()
 {
     $this->setUpEntityManager();
     $test = new Test();
     $test->setValue(self::VALUE);
     $this->em->persist($test);
     $this->em->flush();
     $dbRow = $this->em->getConnection()->fetchAssoc('SELECT * FROM tests WHERE id = ?', [$test->getId()]);
     $this->assertEquals(self::VALUE_TRANSFORMED, $dbRow['value']);
     $this->assertEquals(self::VALUE, $test->getValue());
     $this->em->clear();
     $test = $this->em->find('Transformable\\Fixture\\Test', 1);
     $this->assertEquals(self::VALUE, $test->getValue());
 }
開發者ID:mediamonks,項目名稱:doctrine-extensions,代碼行數:14,代碼來源:TransformableTest.php

示例15: run

 /**
  * Runs all sample data providers.
  *
  * @param callable|null $callback A function that will be called with the name of each provider as a parameter.
  * @return void
  */
 public function run(callable $callback = null)
 {
     $this->em->beginTransaction();
     foreach ($this->providers as $provider) {
         $this->em->clear();
         /** @var $provider \Brick\Sample\SampleDataProvider */
         $provider = $this->injector->instantiate($provider);
         if ($callback) {
             $callback($provider->getName());
         }
         $provider->run();
         $this->em->flush();
     }
     $this->em->commit();
 }
開發者ID:brick,項目名稱:brick,代碼行數:21,代碼來源:SampleDataDispatcher.php


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