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