當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。