Commit 2db54908 authored by Avris's avatar Avris

v4.0

parent bb92a21c
<?php
namespace Avris\Micrus\Doctrine;
use Avris\Micrus\Console\Command\AbstractFixturesCommand;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Application;
abstract class DoctrineFixturesCommand extends AbstractFixturesCommand
{
/** @var EntityManagerInterface */
protected $em;
public function setApplication(Application $application = null)
{
parent::setApplication($application);
$this->em = $this->container->get(EntityManagerInterface::class);
}
protected function truncateDatabase()
{
$connection = $this->em->getConnection();
$platform = $connection->getDatabasePlatform();
$query = 'SET FOREIGN_KEY_CHECKS = 0;';
foreach ($connection->getSchemaManager()->listTables() as $table) {
$query .= $platform->getTruncateTableSQL($table->getName(), true) . ';';
}
$query .= 'SET FOREIGN_KEY_CHECKS = 1;';
$connection->executeQuery($query);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment