当前位置: 首页>>代码示例>>PHP>>正文


PHP ORMExecutor::purge方法代码示例

本文整理汇总了PHP中Doctrine\Common\DataFixtures\Executor\ORMExecutor::purge方法的典型用法代码示例。如果您正苦于以下问题:PHP ORMExecutor::purge方法的具体用法?PHP ORMExecutor::purge怎么用?PHP ORMExecutor::purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\DataFixtures\Executor\ORMExecutor的用法示例。


在下文中一共展示了ORMExecutor::purge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: purgeDb

 /**
  * @BeforeScenario
  */
 public function purgeDb()
 {
     /** @var EntityManagerInterface $em */
     $em = $this->kernel->getContainer()->get('doctrine')->getManager();
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $executor->purge();
 }
开发者ID:stingus,项目名称:Symfony2Behat,代码行数:11,代码来源:FeatureContext.php

示例2: setUp

 /**
  * @BeforeScenario
  */
 public function setUp()
 {
     $entityManager = $this->getContainer()->get('doctrine')->getManager();
     $purger = new ORMPurger($entityManager);
     $executor = new ORMExecutor($entityManager, $purger);
     $executor->purge();
     $entityManager->clear();
 }
开发者ID:lukasz-jakub-adamczuk,项目名称:sapi,代码行数:11,代码来源:FeatureContext.php

示例3: beforeScen

 /**
  * Загружаем необходимые фикстуры перед выполнением сценария
  *
  * @BeforeScenario
  */
 public function beforeScen()
 {
     $loader = new Loader();
     $loader->addFixture(new \Application\Bundle\UserBundle\DataFixtures\ORM\LoadUserData());
     /** @var $em \Doctrine\ORM\EntityManager */
     $em = $this->kernel->getContainer()->get('doctrine')->getManager();
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $executor->purge();
     $executor->execute($loader->getFixtures());
 }
开发者ID:jekakm,项目名称:fwdays,代码行数:16,代码来源:FeatureContext.php

示例4: beforeScen

 /**
  * @BeforeScenario
  */
 public function beforeScen()
 {
     $loader = new Loader();
     $this->getMainContext()->getSubcontext('DoctrineFixturesContext')->loadFixtureClass($loader, 'Stfalcon\\Bundle\\SponsorBundle\\DataFixtures\\ORM\\LoadEventSponsorData');
     /** @var $em \Doctrine\ORM\EntityManager */
     $em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $executor->purge();
     $executor->execute($loader->getFixtures(), true);
 }
开发者ID:bolotyuh,项目名称:fwdays,代码行数:14,代码来源:FeatureContext.php

示例5: purge

 /**
  * {@inheritdoc}
  */
 public function purge()
 {
     $connection = $this->getObjectManager()->getConnection();
     $mysqlPlatform = $this->purger->getPurgeMode() === ORMPurger::PURGE_MODE_TRUNCATE && $connection->getDatabasePlatform() instanceof MySqlPlatform;
     if ($mysqlPlatform) {
         $connection->exec('SET FOREIGN_KEY_CHECKS = 0;');
     }
     parent::purge();
     if ($mysqlPlatform) {
         $connection->exec('SET FOREIGN_KEY_CHECKS = 1;');
     }
 }
开发者ID:Koc,项目名称:AliceBundle,代码行数:15,代码来源:ORMExecutor.php

示例6: purgeTestDatabase

 /** @AfterScenario */
 public function purgeTestDatabase()
 {
     // Purge tables
     $purger = new ORMPurger($this->em);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->purge();
     // Load standard fixtures
     $userFixtures = new LoadUsers();
     $loader = new Loader();
     $loader->addFixture($userFixtures);
     $executor->execute($loader->getFixtures());
 }
开发者ID:NoelLH,项目名称:my-recipes,代码行数:13,代码来源:FeatureContext.php

示例7: beforeScenario

 /**
  * @BeforeScenario
  */
 public function beforeScenario()
 {
     $loader = new Loader();
     $loader->addFixture(new \Stfalcon\Bundle\EventBundle\DataFixtures\ORM\LoadEventData());
     $loader->addFixture(new \Stfalcon\Bundle\EventBundle\DataFixtures\ORM\LoadNewsData());
     $loader->addFixture(new \Application\Bundle\UserBundle\DataFixtures\ORM\LoadUserData());
     $this->em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->em->getConnection()->executeUpdate("SET foreign_key_checks = 0;");
     $purger = new ORMPurger();
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->purge();
     $executor->execute($loader->getFixtures(), true);
     $this->em->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
 }
开发者ID:bolotyuh,项目名称:fwdays,代码行数:18,代码来源:FeatureContext.php

示例8: beforeScen

 /**
  * @BeforeScenario
  */
 public function beforeScen()
 {
     $loader = new Loader();
     $this->getMainContext()->getSubcontext('DoctrineFixturesContext')->loadFixtureClasses($loader, array('Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadNewsData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadPagesData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadReviewData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadMailQueueData', 'Application\\Bundle\\UserBundle\\DataFixtures\\ORM\\LoadUserData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadEventData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadPromoCodeData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadPaymentData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadMailQueueData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadTicketData', 'Stfalcon\\Bundle\\EventBundle\\DataFixtures\\ORM\\LoadMailQueueData'));
     /** @var $em \Doctrine\ORM\EntityManager */
     $em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
     $em->getConnection()->executeUpdate("SET foreign_key_checks = 0;");
     $purger = new ORMPurger();
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($em, $purger);
     $executor->purge();
     $executor->execute($loader->getFixtures(), true);
     $em->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
     /** Maximize browser window */
     $driver = $this->getSession()->getDriver();
     if ($driver instanceof Selenium2Driver) {
         $driver->maximizeWindow();
     }
 }
开发者ID:bolotyuh,项目名称:fwdays,代码行数:22,代码来源:FeatureContext.php

示例9: beforeScen

 /**
  * @BeforeScenario
  */
 public function beforeScen()
 {
     $loader = new Loader();
     $loader->addFixture(new \Stfalcon\Bundle\EventBundle\DataFixtures\ORM\LoadEventData());
     $loader->addFixture(new \Stfalcon\Bundle\EventBundle\DataFixtures\ORM\LoadNewsData());
     $em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
     /** @var $em \Doctrine\ORM\EntityManager */
     $connection = $em->getConnection();
     $connection->beginTransaction();
     $connection->query('SET FOREIGN_KEY_CHECKS=0');
     $connection->commit();
     $purger = new ORMPurger();
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($em, $purger);
     $executor->purge();
     $connection->beginTransaction();
     $connection->query('SET FOREIGN_KEY_CHECKS=1');
     $connection->commit();
     $executor->execute($loader->getFixtures(), true);
 }
开发者ID:jekakm,项目名称:fwdays,代码行数:23,代码来源:FeatureContext.php

示例10: purgeDatabase

 /**
  * @BeforeScenario
  */
 public function purgeDatabase(BeforeScenarioScope $scope)
 {
     $loader = new Loader();
     $loader->addFixture(new \Application\Bundle\CoreBundle\DataFixtures\ORM\LoadSolutionData());
     $loader->addFixture(new \Application\Bundle\CoreBundle\DataFixtures\ORM\LoadTaskData());
     $entityManager = $this->getService('doctrine.orm.entity_manager');
     /** @var $em \Doctrine\ORM\EntityManager */
     $connection = $entityManager->getConnection();
     $connection->beginTransaction();
     $connection->query('SET FOREIGN_KEY_CHECKS=0');
     $connection->commit();
     $purger = new ORMPurger($entityManager);
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($entityManager, $purger);
     $executor->purge();
     $connection->beginTransaction();
     $connection->query('SET FOREIGN_KEY_CHECKS=1');
     $connection->commit();
     $executor->execute($loader->getFixtures(), true);
 }
开发者ID:stfalcon-studio,项目名称:codedill,代码行数:23,代码来源:DefaultContext.php

示例11: purgeDatabase

 /**
  * Purge the Doctrine ORM database
  */
 protected function purgeDatabase()
 {
     /** @var EntityManager $em */
     $em = $this->getEntityManager();
     try {
         $connection = $em->getConnection();
         if ($connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver) {
             $connection->executeUpdate("SET foreign_key_checks = 0;");
         }
         $purger = new ORMPurger();
         $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
         $executor = new ORMExecutor($em, $purger);
         $referenceRepository = new ProxyReferenceRepository($em);
         $executor->setReferenceRepository($referenceRepository);
         $executor->purge();
     } catch (\Exception $ex) {
         throw new RuntimeException(sprintf('Could not purge database! Have you initialized it? Run: ' . PHP_EOL . 'app/console doctrine:database:create --env=test ' . PHP_EOL . 'app/console doctrine:schema:update --force --env=test'));
     }
     if ($connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver) {
         $em->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
     }
 }
开发者ID:sulu,项目名称:SuluPricingBundle,代码行数:25,代码来源:BaseTestCase.php

示例12: purgeDatabase

 /**
  * Purge the Doctrine ORM database.
  */
 protected function purgeDatabase()
 {
     /** @var EntityManager $em */
     $em = $this->db('ORM')->getOm();
     $connection = $em->getConnection();
     if ($connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver) {
         $connection->executeUpdate('SET foreign_key_checks = 0;');
     }
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $referenceRepository = new ProxyReferenceRepository($em);
     $executor->setReferenceRepository($referenceRepository);
     $executor->purge();
     if ($connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver) {
         $em->getConnection()->executeUpdate('SET foreign_key_checks = 1;');
     }
 }
开发者ID:ollietb,项目名称:sulu,代码行数:20,代码来源:SuluTestCase.php

示例13: purgeDatabase

 /**
  * Purge the Doctrine ORM database.
  */
 protected function purgeDatabase()
 {
     if (!self::$kernel->getContainer()->has('doctrine')) {
         return;
     }
     $manager = $this->getEntityManager();
     $connection = $manager->getConnection();
     if ($connection->getDriver() instanceof Driver) {
         $connection->executeUpdate('SET foreign_key_checks = 0;');
     }
     $purger = new ORMPurger();
     $executor = new ORMExecutor($manager, $purger);
     $referenceRepository = new ProxyReferenceRepository($manager);
     $executor->setReferenceRepository($referenceRepository);
     $executor->purge();
     if ($connection->getDriver() instanceof Driver) {
         $connection->executeUpdate('SET foreign_key_checks = 1;');
     }
 }
开发者ID:php-task,项目名称:TaskBundle,代码行数:22,代码来源:BaseCommandTestCase.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     $em = $this->getContainer()->get('doctrine')->getManager();
     if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
         return;
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->purge();
     // Load users
     $stream = fopen($file, 'r');
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_users (id') !== FALSE) {
             break;
         }
     }
     $userManager = $this->getUserManager();
     $userAdmin = $userManager->createUser();
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->setEmail('romain@wildcodeschool.fr');
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $userAdmin->setFirstname('Romain');
     $userAdmin->setLastname('Coeur');
     $userAdmin->setPhone('0628974930');
     $userManager->updateUser($userAdmin);
     $users = array('admin' => $userAdmin);
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $entity = $userManager->createUser();
         $entity->setUsername($data[1]);
         $entity->setUsernameCanonical($data[1]);
         $entity->setEmail($data[1]);
         $entity->setEmailCanonical($data[1]);
         $entity->setEnabled(true);
         $entity->setPlainPassword('wild1234');
         $entity->setPassword('9908e42e69c19bc0e6c0ce1bf05b381fbc94ca10aa7e6b648815d676248f8a3fe2ee124f7d9d375e9f909036e45cc9e766e3c9369655c1db1f331e71c17bc2c9');
         $userManager->updateUser($entity);
         $users[$data[0]] = $entity;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s users loaded</info>', count($users)));
     // Add home data to users
     rewind($stream);
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_homes (id') !== FALSE) {
             break;
         }
     }
     $nb = 0;
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $user = $users[$data[11]];
         $user->setFirstname($data[1]);
         $user->setLastname($data[2]);
         $user->setPhone($data[3]);
         $user->setTelephoneSecondaire($data[4]);
         $user->setAdresse($data[5]);
         $user->setCodePostal($data[6]);
         $user->setCommune($data[7]);
         $user->setModeDePaiement($data[8]);
         $user->setGender($data[9]);
         $user->setCaf($data[10]);
         $em->persist($user);
         $nb++;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s users updated</info>', $nb));
     // Load schools
     rewind($stream);
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_schools (id') !== FALSE) {
             break;
         }
     }
     $schools = array();
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $entity = new School();
         $entity->setName($data[1]);
         $entity->setAdress($data[2]);
         $em->persist($entity);
         $schools[$data[0]] = $entity;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s schools loaded</info>', count($schools)));
//.........这里部分代码省略.........
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:101,代码来源:MigrateCommand.php

示例15: purge

 protected function purge()
 {
     $purger = new ORMPurger($this->em);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->purge();
 }
开发者ID:nicolaskern,项目名称:CCDNUserSecurityBundle,代码行数:6,代码来源:TestBase.php


注:本文中的Doctrine\Common\DataFixtures\Executor\ORMExecutor::purge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。