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


PHP ORMExecutor::setReferenceRepository方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: loadFixtures

 /**
  * Load fixtures into database
  */
 private function loadFixtures()
 {
     $em = $this->entityManager;
     $this->dispatchEvent($em, 'preTruncate');
     $purger = new ORMPurger($em);
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setReferenceRepository($this->getReferenceRepository());
     if (!$this->useBackup) {
         $executor->purge();
     }
     $this->runMigrations();
     $executor->execute($this->fixtures, true);
     $this->dispatchEvent($em, 'postTruncate');
 }
開發者ID:Spomky,項目名稱:DoctrineDataFixturesExtension,代碼行數:18,代碼來源:FixtureService.php


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