vendor/bundles/Symfony/Bundle/DoctrineMigrationsBundle/Command/DoctrineCommand.php
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\DoctrineMigrationsBundle\Command;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\DoctrineBundle\Command\DoctrineCommand as BaseCommand;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
/**
* Base class for Doctrine console commands to extend from.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class DoctrineCommand extends BaseCommand
{
public static function configureMigrations(ContainerInterface $container, Configuration $configuration)
{
$dir = $container->getParameter('doctrine_migrations.dir_name');
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
$configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
$configuration->setMigrationsDirectory($dir);
$configuration->registerMigrationsFromDirectory($dir);
$configuration->setName($container->getParameter('doctrine_migrations.name'));
$configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
}
}