本文整理匯總了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');
}