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