本文整理汇总了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;");
}
}
示例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;');
}
}
示例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;');
}
}
示例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');
}