浏览代码

Changing --em option description consistant across all commands

Jonathan H. Wage 15 年之前
父节点
当前提交
ae82308eff

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/ClearMetadataCacheDoctrineCommand.php

@@ -33,7 +33,7 @@ class ClearMetadataCacheDoctrineCommand extends MetadataCommand
     $this
       ->setName('doctrine:cache:clear-metadata')
       ->setDescription('Clear all metadata cache for a entity manager.')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to clear the cache for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:cache:clear-metadata</info> command clears all metadata cache for the default entity manager:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/ClearQueryCacheDoctrineCommand.php

@@ -33,7 +33,7 @@ class ClearQueryCacheDoctrineCommand extends QueryCommand
     $this
       ->setName('doctrine:cache:clear-query')
       ->setDescription('Clear all query cache for a entity manager.')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to clear the cache for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:cache:clear-query</info> command clears all query cache for the default entity manager:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/ClearResultCacheDoctrineCommand.php

@@ -33,7 +33,7 @@ class ClearResultCacheDoctrineCommand extends ResultCommand
     $this
       ->setName('doctrine:cache:clear-result')
       ->setDescription('Clear result cache for a entity manager.')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to clear the cache for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:cache:clear-result</info> command clears all result cache for the default entity manager:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/ConvertMappingDoctrineCommand.php

@@ -34,7 +34,7 @@ class ConvertMappingDoctrineCommand extends ConvertMappingCommand
     parent::configure();
     $this
       ->setName('doctrine:mapping:convert')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to convert the mapping information from.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:mapping:convert</info> command converts mapping information between supported formats:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/CreateDatabaseDoctrineCommand.php

@@ -36,7 +36,7 @@ class CreateDatabaseDoctrineCommand extends DoctrineCommand
     $this
       ->setName('doctrine:database:create')
       ->setDescription('Create the configured databases.')
-      ->addOption('connection', null, null, 'The connection name to create the database for.')
+      ->addOption('connection', null, InputOption::PARAMETER_OPTIONAL, 'The connection to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:database:create</info> command creates the default connections database:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/CreateSchemaDoctrineCommand.php

@@ -34,7 +34,7 @@ class CreateSchemaDoctrineCommand extends CreateCommand
 
     $this
       ->setName('doctrine:schema:create')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to create the schema for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:schema:create</info> command creates the default entity managers schema:
 

+ 19 - 0
src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php

@@ -17,6 +17,8 @@ use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
 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.
@@ -36,6 +38,23 @@ use Doctrine\ORM\Tools\EntityGenerator;
  */
 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();

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/DropDatabaseDoctrineCommand.php

@@ -36,7 +36,7 @@ class DropDatabaseDoctrineCommand extends DoctrineCommand
     $this
       ->setName('doctrine:database:drop')
       ->setDescription('Drop the configured databases.')
-      ->addOption('connection', null, null, 'The connection name to create the database for.')
+      ->addOption('connection', null, InputOption::PARAMETER_OPTIONAL, 'The connection to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:database:drop</info> command drops the default connections database:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/DropSchemaDoctrineCommand.php

@@ -34,7 +34,7 @@ class DropSchemaDoctrineCommand extends DropCommand
 
     $this
       ->setName('doctrine:schema:drop')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to drop the schema for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:schema:drop</info> command drops the default entity managers schema:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/EnsureProductionSettingsDoctrineCommand.php

@@ -34,7 +34,7 @@ class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCo
 
     $this
       ->setName('doctrine:ensure-production-settings')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to ensure production settings for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:cache:clear-metadata</info> command clears all metadata cache for the default entity manager:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php

@@ -34,7 +34,7 @@ class GenerateProxiesDoctrineCommand extends GenerateProxiesCommand
 
     $this
       ->setName('doctrine:generate:proxies')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to generate proxies for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:generate:proxies</info> command generates proxy classes for your entities:
 

+ 2 - 2
src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php

@@ -39,7 +39,7 @@ class ImportMappingDoctrineCommand extends DoctrineCommand
       ->setName('doctrine:mapping:import')
       ->addArgument('bundle', InputArgument::REQUIRED, 'The bundle to import the mapping information to.')
       ->addArgument('mapping-type', InputArgument::OPTIONAL, 'The mapping type to export the imported mapping information to.')
-      ->addArgument('em', InputArgument::OPTIONAL, 'The entity manager to import the mapping information from.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setDescription('Import mapping information from an existing database.')
       ->setHelp(<<<EOT
 The <info>doctrine:mapping:import</info> command imports mapping information from an existing database:
@@ -93,7 +93,7 @@ EOT
       $exporter->setEntityGenerator($entityGenerator);
     }
 
-    $emName = $input->getArgument('em') ? $input->getArgument('em') : 'default';
+    $emName = $input->getOption('em') ? $input->getOption('em') : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->getService($emServiceName);
     $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php

@@ -34,7 +34,7 @@ class RunDqlDoctrineCommand extends RunDqlCommand
 
     $this
       ->setName('doctrine:query:dql')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to execute the DQL query on.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:query:dql</info> command executes the given DQL query and outputs the results:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php

@@ -34,7 +34,7 @@ class RunSqlDoctrineCommand extends RunSqlCommand
 
     $this
       ->setName('doctrine:query:sql')
-      ->addOption('connection', null, null, 'The connection to execute the SQL query on.')
+      ->addOption('connection', null, InputOption::PARAMETER_OPTIONAL, 'The connection to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:query:sql</info> command executes the given DQL query and outputs the results:
 

+ 1 - 1
src/Symfony/Framework/DoctrineBundle/Command/UpdateSchemaDoctrineCommand.php

@@ -34,7 +34,7 @@ class UpdateSchemaDoctrineCommand extends UpdateCommand
 
     $this
       ->setName('doctrine:schema:update')
-      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to update the schema for.')
+      ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
       ->setHelp(<<<EOT
 The <info>doctrine:schema:update</info> command updates the default entity managers schema: