Skip to content

Commit

Permalink
Moved migrations-specific method out of DoctrineBundle\Command\Doctri…
Browse files Browse the repository at this point in the history
…neCommand and into the migrations bundle.
  • Loading branch information
xdissent authored and fabpot committed May 25, 2010
1 parent 0512d13 commit 5a09375
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
19 changes: 0 additions & 19 deletions src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php
Expand Up @@ -17,8 +17,6 @@
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Tools\EntityGenerator;
use DoctrineExtensions\Migrations\Configuration\Configuration;
use Doctrine\Common\Util\Inflector;

/*
* This file is part of the Symfony framework.
Expand All @@ -38,23 +36,6 @@
*/
abstract class DoctrineCommand extends Command
{
public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
{
$configuration->setMigrationsNamespace($bundle.'\DoctrineMigrations');

$dirs = $application->getKernel()->getBundleDirs();

$tmp = str_replace('\\', '/', $bundle);
$namespace = str_replace('/', '\\', dirname($tmp));
$bundle = basename($tmp);

$dir = $dirs[$namespace].'/'.$bundle.'/DoctrineMigrations';
$configuration->setMigrationsDirectory($dir);
$configuration->registerMigrationsFromDirectory($dir);
$configuration->setName($bundle.' Migrations');
$configuration->setMigrationsTableName(Inflector::tableize($bundle).'_migration_versions');
}

public static function setApplicationEntityManager(Application $application, $emName)
{
$container = $application->getKernel()->getContainer();
Expand Down
@@ -0,0 +1,44 @@
<?php

namespace Symfony\Framework\DoctrineMigrationsBundle\Command;

use Symfony\Framework\WebBundle\Console\Application;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand as BaseCommand;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\Common\Util\Inflector;

/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

/**
* Base class for Doctrine console commands to extend from.
*
* @package Symfony
* @subpackage Framework_DoctrineBundle
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
abstract class DoctrineCommand extends BaseCommand
{
public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
{
$configuration->setMigrationsNamespace($bundle.'\DoctrineMigrations');

$dirs = $application->getKernel()->getBundleDirs();

$tmp = str_replace('\\', '/', $bundle);
$namespace = str_replace('/', '\\', dirname($tmp));
$bundle = basename($tmp);

$dir = $dirs[$namespace].'/'.$bundle.'/DoctrineMigrations';
$configuration->setMigrationsDirectory($dir);
$configuration->registerMigrationsFromDirectory($dir);
$configuration->setName($bundle.' Migrations');
$configuration->setMigrationsTableName(Inflector::tableize($bundle).'_migration_versions');
}
}
Expand Up @@ -5,7 +5,6 @@
use Symfony\Components\Console\Input\InputInterface;
use Symfony\Components\Console\Output\OutputInterface;
use Symfony\Components\Console\Input\InputOption;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand;

/*
Expand Down
Expand Up @@ -5,7 +5,6 @@
use Symfony\Components\Console\Input\InputInterface;
use Symfony\Components\Console\Output\OutputInterface;
use Symfony\Components\Console\Input\InputOption;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand;

/*
Expand Down
Expand Up @@ -5,7 +5,6 @@
use Symfony\Components\Console\Input\InputInterface;
use Symfony\Components\Console\Output\OutputInterface;
use Symfony\Components\Console\Input\InputOption;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;

/*
Expand Down
Expand Up @@ -5,7 +5,6 @@
use Symfony\Components\Console\Input\InputInterface;
use Symfony\Components\Console\Output\OutputInterface;
use Symfony\Components\Console\Input\InputOption;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand;

/*
Expand Down
Expand Up @@ -5,7 +5,6 @@
use Symfony\Components\Console\Input\InputInterface;
use Symfony\Components\Console\Output\OutputInterface;
use Symfony\Components\Console\Input\InputOption;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand;

/*
Expand Down
Expand Up @@ -5,7 +5,6 @@
use Symfony\Components\Console\Input\InputInterface;
use Symfony\Components\Console\Output\OutputInterface;
use Symfony\Components\Console\Input\InputOption;
use Symfony\Framework\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand;

/*
Expand Down

0 comments on commit 5a09375

Please sign in to comment.