protected function execute(InputInterface $input, OutputInterface $output)
{
$database = $this->getContainer()->get('ezpublish.connection')->getConnection()->getParams();
if (is_array($database)) {
$driverMap = array('pdo_mysql' => 'mysql', 'pdo_pgsql' => 'pgsql', 'pdo_sqlite' => 'sqlite');
$dbType = $driverMap[$database['driver']];
$database = $database['dbname'];
} else {
$dbType = preg_replace('(^([a-z]+).*)', '\\1', $database);
}
if ($input->isInteractive() && !$this->getHelperSet()->get('dialog')->askConfirmation($output, "<question>Are you sure you want to delete all data in '{$database}' database?</question>", false)) {
return;
}
$output->writeln('<info>Database is now being emptied and re filled with fixture data.</info>');
// @TODO Reuse API Integration tests SetupFactory when it has been refactored to be able to use Symfony DIC
$this->applyStatements($this->getSchemaStatements($dbType));
$this->insertData($dbType);
}