From 214dc9896b83a0f867c1c4ff5641e4eac7f1c530 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 23 Nov 2017 11:18:08 +0100 Subject: [PATCH] Use addOption()/addArgument() to configure commands In order to simplify and standardise the definition of the commands. --- .../ClearCache/CollectionRegionCommand.php | 29 ++++---- .../ClearCache/EntityRegionCommand.php | 25 +++---- .../Command/ClearCache/MetadataCommand.php | 27 +++---- .../Command/ClearCache/QueryCommand.php | 27 +++---- .../Command/ClearCache/QueryRegionCommand.php | 23 +++--- .../Command/ClearCache/ResultCommand.php | 23 ++---- .../Command/ConvertDoctrine1SchemaCommand.php | 55 ++++----------- .../Console/Command/ConvertMappingCommand.php | 69 ++++++------------ .../EnsureProductionSettingsCommand.php | 21 ++---- .../Command/GenerateEntitiesCommand.php | 70 +++++-------------- .../Command/GenerateProxiesCommand.php | 36 ++++------ .../Command/GenerateRepositoriesCommand.php | 33 +++------ .../ORM/Tools/Console/Command/InfoCommand.php | 13 ++-- .../Command/MappingDescribeCommand.php | 18 +++-- .../Tools/Console/Command/RunDqlCommand.php | 54 ++++---------- .../Command/SchemaTool/AbstractCommand.php | 4 +- .../Command/SchemaTool/CreateCommand.php | 26 +++---- .../Command/SchemaTool/DropCommand.php | 36 +++------- .../Command/SchemaTool/UpdateCommand.php | 38 +++------- .../Console/Command/ValidateSchemaCommand.php | 27 ++----- 20 files changed, 206 insertions(+), 448 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php index f12bfa560..8c73cf793 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php @@ -19,13 +19,13 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; +use Doctrine\ORM\Cache; +use Doctrine\ORM\Cache\Region\DefaultRegion; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\ORM\Cache\Region\DefaultRegion; -use Doctrine\ORM\Cache; /** * Command to clear a collection cache region. @@ -40,17 +40,14 @@ class CollectionRegionCommand extends Command */ protected function configure() { - $this - ->setName('orm:clear-cache:region:collection') - ->setDescription('Clear a second-level cache collection region.') - ->addArgument('owner-class', InputArgument::OPTIONAL, 'The owner entity name.') - ->addArgument('association', InputArgument::OPTIONAL, 'The association collection name.') - ->addArgument('owner-id', InputArgument::OPTIONAL, 'The owner identifier.') - ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') - ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.'); - - - $this->setHelp(<<setName('orm:clear-cache:region:collection') + ->setDescription('Clear a second-level cache collection region') + ->addArgument('owner-class', InputArgument::OPTIONAL, 'The owner entity name.') + ->addArgument('association', InputArgument::OPTIONAL, 'The association collection name.') + ->addArgument('owner-id', InputArgument::OPTIONAL, 'The owner identifier.') + ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.') + ->setHelp(<<%command.name% command is meant to clear a second-level cache collection regions for an associated Entity Manager. It is possible to delete/invalidate all collection region, a specific collection region or flushes the cache provider. @@ -74,7 +71,7 @@ Alternatively, if you want to flush the configured cache provider for an collect Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. EOT - ); + ); } /** @@ -92,7 +89,7 @@ EOT throw new \InvalidArgumentException('No second-level cache is configured on the given EntityManager.'); } - if ( (! $ownerClass || ! $assoc) && ! $input->getOption('all')) { + if (( ! $ownerClass || ! $assoc) && ! $input->getOption('all')) { throw new \InvalidArgumentException('Missing arguments "--owner-class" "--association"'); } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php index 0258b7de2..ff9e3688b 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php @@ -19,13 +19,13 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; +use Doctrine\ORM\Cache; +use Doctrine\ORM\Cache\Region\DefaultRegion; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\ORM\Cache\Region\DefaultRegion; -use Doctrine\ORM\Cache; /** * Command to clear a entity cache region. @@ -40,16 +40,13 @@ class EntityRegionCommand extends Command */ protected function configure() { - $this - ->setName('orm:clear-cache:region:entity') - ->setDescription('Clear a second-level cache entity region.') - ->addArgument('entity-class', InputArgument::OPTIONAL, 'The entity name.') - ->addArgument('entity-id', InputArgument::OPTIONAL, 'The entity identifier.') - ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') - ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.'); - - - $this->setHelp(<<setName('orm:clear-cache:region:entity') + ->setDescription('Clear a second-level cache entity region') + ->addArgument('entity-class', InputArgument::OPTIONAL, 'The entity name.') + ->addArgument('entity-id', InputArgument::OPTIONAL, 'The entity identifier.') + ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.') + ->setHelp(<<%command.name% command is meant to clear a second-level cache entity region for an associated Entity Manager. It is possible to delete/invalidate all entity region, a specific entity region or flushes the cache provider. @@ -73,7 +70,7 @@ Alternatively, if you want to flush the configured cache provider for an entity Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php index 5bc0c859d..64b6a0615 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -19,12 +19,12 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Doctrine\Common\Cache\ApcCache; use Doctrine\Common\Cache\XcacheCache; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to clear the metadata cache of the various cache drivers. @@ -43,19 +43,10 @@ class MetadataCommand extends Command */ protected function configure() { - $this - ->setName('orm:clear-cache:metadata') - ->setDescription('Clear all metadata cache of the various cache drivers.') - ->setDefinition( - [ - new InputOption( - 'flush', null, InputOption::VALUE_NONE, - 'If defined, cache entries will be flushed instead of deleted/invalidated.' - ) - ] - ); - - $this->setHelp(<<setName('orm:clear-cache:metadata') + ->setDescription('Clear all metadata cache of the various cache drivers') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') + ->setHelp(<<%command.name% command is meant to clear the metadata cache of associated Entity Manager. It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider instance completely. @@ -72,7 +63,7 @@ Alternatively, if you want to flush the cache provider using this command: Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php index 5828d0771..b4619bd7f 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -19,12 +19,12 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Doctrine\Common\Cache\ApcCache; use Doctrine\Common\Cache\XcacheCache; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to clear the query cache of the various cache drivers. @@ -43,19 +43,10 @@ class QueryCommand extends Command */ protected function configure() { - $this - ->setName('orm:clear-cache:query') - ->setDescription('Clear all query cache of the various cache drivers.') - ->setDefinition( - [ - new InputOption( - 'flush', null, InputOption::VALUE_NONE, - 'If defined, cache entries will be flushed instead of deleted/invalidated.' - ) - ] - ); - - $this->setHelp(<<setName('orm:clear-cache:query') + ->setDescription('Clear all query cache of the various cache drivers') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') + ->setHelp(<<%command.name% command is meant to clear the query cache of associated Entity Manager. It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider instance completely. @@ -72,7 +63,7 @@ Alternatively, if you want to flush the cache provider using this command: Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php index 0637c7a4a..9492958b1 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php @@ -19,13 +19,13 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; +use Doctrine\ORM\Cache; +use Doctrine\ORM\Cache\Region\DefaultRegion; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\ORM\Cache\Region\DefaultRegion; -use Doctrine\ORM\Cache; /** * Command to clear a query cache region. @@ -40,15 +40,12 @@ class QueryRegionCommand extends Command */ protected function configure() { - $this - ->setName('orm:clear-cache:region:query') - ->setDescription('Clear a second-level cache query region.') - ->addArgument('region-name', InputArgument::OPTIONAL, 'The query region to clear.') - ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all query regions will be deleted/invalidated.') - ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.'); - - - $this->setHelp(<<setName('orm:clear-cache:region:query') + ->setDescription('Clear a second-level cache query region') + ->addArgument('region-name', InputArgument::OPTIONAL, 'The query region to clear.') + ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all query regions will be deleted/invalidated.') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.') + ->setHelp(<<%command.name% command is meant to clear a second-level cache query region for an associated Entity Manager. It is possible to delete/invalidate all query region, a specific query region or flushes the cache provider. @@ -72,7 +69,7 @@ Alternatively, if you want to flush the configured cache provider use this comma Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php index 55b89efa8..6b00c1233 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -19,12 +19,12 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; +use Doctrine\Common\Cache\ApcCache; +use Doctrine\Common\Cache\XcacheCache; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Cache\ApcCache; -use Doctrine\Common\Cache\XcacheCache; /** * Command to clear the result cache of the various cache drivers. @@ -43,19 +43,10 @@ class ResultCommand extends Command */ protected function configure() { - $this - ->setName('orm:clear-cache:result') - ->setDescription('Clear all result cache of the various cache drivers.') - ->setDefinition( - [ - new InputOption( - 'flush', null, InputOption::VALUE_NONE, - 'If defined, cache entries will be flushed instead of deleted/invalidated.' - ) - ] - ); - - $this->setHelp(<<setName('orm:clear-cache:result') + ->setDescription('Clear all result cache of the various cache drivers') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') + ->setHelp(<<%command.name% command is meant to clear the result cache of associated Entity Manager. It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider instance completely. @@ -72,7 +63,7 @@ Alternatively, if you want to flush the cache provider using this command: Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php index 6c81de940..b6b43bf8e 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php @@ -19,14 +19,14 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\ORM\Tools\Export\ClassMetadataExporter; use Doctrine\ORM\Tools\ConvertDoctrine1Schema; use Doctrine\ORM\Tools\EntityGenerator; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Doctrine\ORM\Tools\Export\ClassMetadataExporter; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to convert a Doctrine 1 schema to a Doctrine 2 mapping file. @@ -99,41 +99,16 @@ class ConvertDoctrine1SchemaCommand extends Command */ protected function configure() { - $this - ->setName('orm:convert-d1-schema') - ->setAliases(['orm:convert:d1-schema']) - ->setDescription('Converts Doctrine 1.X schema into a Doctrine 2.X schema.') - ->setDefinition( - [ - new InputArgument( - 'from-path', InputArgument::REQUIRED, 'The path of Doctrine 1.X schema information.' - ), - new InputArgument( - 'to-type', InputArgument::REQUIRED, 'The destination Doctrine 2.X mapping type.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, - 'The path to generate your Doctrine 2.X mapping information.' - ), - new InputOption( - 'from', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'Optional paths of Doctrine 1.X schema information.', - [] - ), - new InputOption( - 'extend', null, InputOption::VALUE_OPTIONAL, - 'Defines a base class to be extended by generated entity classes.' - ), - new InputOption( - 'num-spaces', null, InputOption::VALUE_OPTIONAL, - 'Defines the number of indentation spaces', 4 - ) - ] - ) - ->setHelp(<<setName('orm:convert-d1-schema') + ->setAliases(['orm:convert:d1-schema']) + ->setDescription('Converts Doctrine 1.x schema into a Doctrine 2.x schema') + ->addArgument('from-path', InputArgument::REQUIRED, 'The path of Doctrine 1.X schema information.') + ->addArgument('to-type', InputArgument::REQUIRED, 'The destination Doctrine 2.X mapping type.') + ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your Doctrine 2.X mapping information.') + ->addOption('from', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Optional paths of Doctrine 1.X schema information.', []) + ->addOption('extend', null, InputOption::VALUE_OPTIONAL, 'Defines a base class to be extended by generated entity classes.') + ->addOption('num-spaces', null, InputOption::VALUE_OPTIONAL, 'Defines the number of indentation spaces', 4) + ->setHelp('Converts Doctrine 1.x schema into a Doctrine 2.x schema.'); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php index 798dbe728..6b9153f01 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php @@ -19,16 +19,16 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\ORM\Tools\Console\MetadataFilter; -use Doctrine\ORM\Tools\Export\ClassMetadataExporter; -use Doctrine\ORM\Tools\EntityGenerator; -use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; use Doctrine\ORM\Mapping\Driver\DatabaseDriver; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Doctrine\ORM\Tools\Console\MetadataFilter; +use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; +use Doctrine\ORM\Tools\EntityGenerator; +use Doctrine\ORM\Tools\Export\ClassMetadataExporter; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to convert your mapping information between the various formats. @@ -47,45 +47,18 @@ class ConvertMappingCommand extends Command */ protected function configure() { - $this - ->setName('orm:convert-mapping') - ->setAliases(['orm:convert:mapping']) - ->setDescription('Convert mapping information between supported formats.') - ->setDefinition( - [ - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'to-type', InputArgument::REQUIRED, 'The mapping type to be converted.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, - 'The path to generate your entities classes.' - ), - new InputOption( - 'force', 'f', InputOption::VALUE_NONE, - 'Force to overwrite existing mapping files.' - ), - new InputOption( - 'from-database', null, null, 'Whether or not to convert mapping information from existing database.' - ), - new InputOption( - 'extend', null, InputOption::VALUE_OPTIONAL, - 'Defines a base class to be extended by generated entity classes.' - ), - new InputOption( - 'num-spaces', null, InputOption::VALUE_OPTIONAL, - 'Defines the number of indentation spaces', 4 - ), - new InputOption( - 'namespace', null, InputOption::VALUE_OPTIONAL, - 'Defines a namespace for the generated entity classes, if converted from database.' - ), - ] - ) - ->setHelp(<<setName('orm:convert-mapping') + ->setAliases(['orm:convert:mapping']) + ->setDescription('Convert mapping information between supported formats') + ->addArgument('to-type', InputArgument::REQUIRED, 'The mapping type to be converted.') + ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your entities classes.') + ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') + ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force to overwrite existing mapping files.') + ->addOption('from-database', null, null, 'Whether or not to convert mapping information from existing database.') + ->addOption('extend', null, InputOption::VALUE_OPTIONAL, 'Defines a base class to be extended by generated entity classes.') + ->addOption('num-spaces', null, InputOption::VALUE_OPTIONAL, 'Defines the number of indentation spaces', 4) + ->addOption('namespace', null, InputOption::VALUE_OPTIONAL, 'Defines a namespace for the generated entity classes, if converted from database.') + ->setHelp(<<one-time command. It should not be necessary for @@ -108,7 +81,7 @@ on a global level: \$config->setFilterSchemaAssetsExpression(\$regexp); EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php index 180254f9c..0a986bce1 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php @@ -20,8 +20,8 @@ namespace Doctrine\ORM\Tools\Console\Command; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Throwable; @@ -43,21 +43,10 @@ class EnsureProductionSettingsCommand extends Command */ protected function configure() { - $this - ->setName('orm:ensure-production-settings') - ->setDescription('Verify that Doctrine is properly configured for a production environment.') - ->setDefinition( - [ - new InputOption( - 'complete', null, InputOption::VALUE_NONE, - 'Flag to also inspect database connection existence.' - ) - ] - ) - ->setHelp(<<setName('orm:ensure-production-settings') + ->setDescription('Verify that Doctrine is properly configured for a production environment') + ->addOption('complete', null, InputOption::VALUE_NONE, 'Flag to also inspect database connection existence.') + ->setHelp('Verify that Doctrine is properly configured for a production environment.'); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php index 080bfc97a..58d19774c 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php @@ -19,14 +19,14 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Doctrine\ORM\Tools\Console\MetadataFilter; -use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Doctrine\ORM\Tools\EntityGenerator; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to generate entity classes and method stubs from your mapping information. @@ -45,50 +45,19 @@ class GenerateEntitiesCommand extends Command */ protected function configure() { - $this - ->setName('orm:generate-entities') - ->setAliases(['orm:generate:entities']) - ->setDescription('Generate entity classes and method stubs from your mapping information.') - ->setDefinition( - [ - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, 'The path to generate your entity classes.' - ), - new InputOption( - 'generate-annotations', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should generate annotation metadata on entities.', false - ), - new InputOption( - 'generate-methods', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should generate stub methods on entities.', true - ), - new InputOption( - 'regenerate-entities', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should regenerate entity if it exists.', false - ), - new InputOption( - 'update-entities', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should only update entity if it exists.', true - ), - new InputOption( - 'extend', null, InputOption::VALUE_REQUIRED, - 'Defines a base class to be extended by generated entity classes.' - ), - new InputOption( - 'num-spaces', null, InputOption::VALUE_REQUIRED, - 'Defines the number of indentation spaces', 4 - ), - new InputOption( - 'no-backup', null, InputOption::VALUE_NONE, - 'Flag to define if generator should avoid backuping existing entity file if it exists.' - ) - ] - ) - ->setHelp(<<setName('orm:generate-entities') + ->setAliases(['orm:generate:entities']) + ->setDescription('Generate entity classes and method stubs from your mapping information') + ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your entity classes.') + ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') + ->addOption('generate-annotations', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should generate annotation metadata on entities.', false) + ->addOption('generate-methods', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should generate stub methods on entities.', true) + ->addOption('regenerate-entities', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should regenerate entity if it exists.', false) + ->addOption('update-entities', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should only update entity if it exists.', true) + ->addOption('extend', null, InputOption::VALUE_REQUIRED, 'Defines a base class to be extended by generated entity classes.') + ->addOption('num-spaces', null, InputOption::VALUE_REQUIRED, 'Defines the number of indentation spaces', 4) + ->addOption('no-backup', null, InputOption::VALUE_NONE, 'Flag to define if generator should avoid backuping existing entity file if it exists.') + ->setHelp(<<--update-entities or --regenerate-entities flags your existing @@ -108,7 +77,7 @@ child classes for you correctly, because it doesn't know which class is supposed to extend which. You have to adjust the entity code manually for inheritance to work! EOT - ); + ); } /** @@ -139,7 +108,6 @@ EOT } if (count($metadatas)) { - // Create EntityGenerator $entityGenerator = new EntityGenerator(); $entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations')); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php index 9475bca71..682b0fc4c 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php @@ -19,12 +19,13 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Tools\Console\MetadataFilter; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to (re)generate the proxy classes used by doctrine. @@ -43,26 +44,12 @@ class GenerateProxiesCommand extends Command */ protected function configure() { - $this - ->setName('orm:generate-proxies') - ->setAliases(['orm:generate:proxies']) - ->setDescription('Generates proxy classes for entity classes.') - ->setDefinition( - [ - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'dest-path', InputArgument::OPTIONAL, - 'The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration.' - ), - ] - ) - ->setHelp(<<setName('orm:generate-proxies') + ->setAliases(['orm:generate:proxies']) + ->setDescription('Generates proxy classes for entity classes') + ->addArgument('dest-path', InputArgument::OPTIONAL, 'The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration.') + ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') + ->setHelp('Generates proxy classes for entity classes.'); } /** @@ -70,6 +57,7 @@ EOT */ protected function execute(InputInterface $input, OutputInterface $output) { + /** @var EntityManagerInterface $em */ $em = $this->getHelper('em')->getEntityManager(); $metadatas = $em->getMetadataFactory()->getAllMetadata(); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php index 1da7a85c1..81081a442 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php @@ -19,13 +19,13 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Doctrine\ORM\Tools\Console\MetadataFilter; use Doctrine\ORM\Tools\EntityRepositoryGenerator; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to generate repository classes for mapping information. @@ -44,25 +44,12 @@ class GenerateRepositoriesCommand extends Command */ protected function configure() { - $this - ->setName('orm:generate-repositories') - ->setAliases(['orm:generate:repositories']) - ->setDescription('Generate repository classes from your mapping information.') - ->setDefinition( - [ - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, 'The path to generate your repository classes.' - ) - ] - ) - ->setHelp(<<setName('orm:generate-repositories') + ->setAliases(['orm:generate:repositories']) + ->setDescription('Generate repository classes from your mapping information') + ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your repository classes.') + ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') + ->setHelp('Generate repository classes from your mapping information.'); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php index 560d18718..6cf73ee76 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php @@ -20,9 +20,9 @@ namespace Doctrine\ORM\Tools\Console\Command; use Doctrine\ORM\Mapping\MappingException; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; /** * Show information about mapped entities. @@ -38,15 +38,14 @@ class InfoCommand extends Command */ protected function configure() { - $this - ->setName('orm:info') - ->setDescription('Show basic information about all mapped entities') - ->setHelp(<<setName('orm:info') + ->setDescription('Show basic information about all mapped entities') + ->setHelp(<<%command.name% shows basic information about which entities exist and possibly if their mapping information contains errors or not. EOT - ); + ); } /** @@ -61,7 +60,7 @@ EOT ->getMetadataDriverImpl() ->getAllClassNames(); - if (!$entityClassNames) { + if ( ! $entityClassNames) { throw new \Exception( 'You do not have any mapped Doctrine ORM entities according to the current configuration. '. 'If you have entities or mapping files you should check your mapping configuration for errors.' diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 6f2761e0d..8eca10197 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -41,11 +41,10 @@ final class MappingDescribeCommand extends Command */ protected function configure() { - $this - ->setName('orm:mapping:describe') - ->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity') - ->setDescription('Display information about mapped objects') - ->setHelp(<<setName('orm:mapping:describe') + ->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity') + ->setDescription('Display information about mapped objects') + ->setHelp(<<%command.full_name% My\Namespace\Entity\MyEntity @@ -54,7 +53,7 @@ Or: %command.full_name% MyEntity EOT - ); + ); } /** @@ -138,10 +137,9 @@ EOT */ private function getMappedEntities(EntityManagerInterface $entityManager) { - $entityClassNames = $entityManager - ->getConfiguration() - ->getMetadataDriverImpl() - ->getAllClassNames(); + $entityClassNames = $entityManager->getConfiguration() + ->getMetadataDriverImpl() + ->getAllClassNames(); if ( ! $entityClassNames) { throw new \InvalidArgumentException( diff --git a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php index b246850a9..14191515b 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php @@ -19,12 +19,12 @@ namespace Doctrine\ORM\Tools\Console\Command; +use Doctrine\Common\Util\Debug; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Util\Debug; /** * Command to execute DQL queries in a given EntityManager. @@ -43,39 +43,15 @@ class RunDqlCommand extends Command */ protected function configure() { - $this - ->setName('orm:run-dql') - ->setDescription('Executes arbitrary DQL directly from the command line.') - ->setDefinition( - [ - new InputArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.'), - new InputOption( - 'hydrate', null, InputOption::VALUE_REQUIRED, - 'Hydration mode of result set. Should be either: object, array, scalar or single-scalar.', - 'object' - ), - new InputOption( - 'first-result', null, InputOption::VALUE_REQUIRED, - 'The first result in the result set.' - ), - new InputOption( - 'max-result', null, InputOption::VALUE_REQUIRED, - 'The maximum number of results in the result set.' - ), - new InputOption( - 'depth', null, InputOption::VALUE_REQUIRED, - 'Dumping depth of Entity graph.', 7 - ), - new InputOption( - 'show-sql', null, InputOption::VALUE_NONE, - 'Dump generated SQL instead of executing query' - ) - ] - ) - ->setHelp(<<setName('orm:run-dql') + ->setDescription('Executes arbitrary DQL directly from the command line') + ->addArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.') + ->addOption('hydrate', null, InputOption::VALUE_REQUIRED, 'Hydration mode of result set. Should be either: object, array, scalar or single-scalar.', 'object') + ->addOption('first-result', null, InputOption::VALUE_REQUIRED, 'The first result in the result set.') + ->addOption('max-result', null, InputOption::VALUE_REQUIRED, 'The maximum number of results in the result set.') + ->addOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of Entity graph.', 7) + ->addOption('show-sql', null, InputOption::VALUE_NONE, 'Dump generated SQL instead of executing query') + ->setHelp('Executes arbitrary DQL directly from the command line.'); } /** @@ -87,13 +63,13 @@ EOT $em = $this->getHelper('em')->getEntityManager(); if (($dql = $input->getArgument('dql')) === null) { - throw new \RuntimeException("Argument 'DQL' is required in order to execute this command correctly."); + throw new \RuntimeException("Argument 'dql' is required in order to execute this command correctly."); } $depth = $input->getOption('depth'); if ( ! is_numeric($depth)) { - throw new \LogicException("Option 'depth' must contains an integer value"); + throw new \LogicException("Option 'depth' must contain an integer value"); } $hydrationModeName = $input->getOption('hydrate'); @@ -109,7 +85,7 @@ EOT if (($firstResult = $input->getOption('first-result')) !== null) { if ( ! is_numeric($firstResult)) { - throw new \LogicException("Option 'first-result' must contains an integer value"); + throw new \LogicException("Option 'first-result' must contain an integer value"); } $query->setFirstResult((int) $firstResult); @@ -117,7 +93,7 @@ EOT if (($maxResult = $input->getOption('max-result')) !== null) { if ( ! is_numeric($maxResult)) { - throw new \LogicException("Option 'max-result' must contains an integer value"); + throw new \LogicException("Option 'max-result' must contain an integer value"); } $query->setMaxResults((int) $maxResult); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php index dc7e7ec7e..ed9d754ed 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php @@ -19,10 +19,10 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; +use Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Doctrine\ORM\Tools\SchemaTool; /** * Base class for CreateCommand, DropCommand and UpdateCommand. diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php index 73fbcbabb..a4486469d 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php @@ -19,10 +19,10 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to create the database schema for a set of classes based on their mappings. @@ -41,20 +41,10 @@ class CreateCommand extends AbstractCommand */ protected function configure() { - $this - ->setName('orm:schema-tool:create') - ->setDescription( - 'Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.' - ) - ->setDefinition( - [ - new InputOption( - 'dump-sql', null, InputOption::VALUE_NONE, - 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.' - ) - ] - ) - ->setHelp(<<setName('orm:schema-tool:create') + ->setDescription('Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output') + ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.') + ->setHelp(<<Hint: If you have a database with tables that should not be managed @@ -63,7 +53,7 @@ on a global level: \$config->setFilterSchemaAssetsExpression(\$regexp); EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php index e28347039..be4d55a95 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php @@ -19,10 +19,10 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to drop the database schema for a set of classes based on their mappings. @@ -41,28 +41,12 @@ class DropCommand extends AbstractCommand */ protected function configure() { - $this - ->setName('orm:schema-tool:drop') - ->setDescription( - 'Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output.' - ) - ->setDefinition( - [ - new InputOption( - 'dump-sql', null, InputOption::VALUE_NONE, - 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.' - ), - new InputOption( - 'force', 'f', InputOption::VALUE_NONE, - "Don't ask for the deletion of the database, but force the operation to run." - ), - new InputOption( - 'full-database', null, InputOption::VALUE_NONE, - 'Instead of using the Class Metadata to detect the database table schema, drop ALL assets that the database contains.' - ), - ] - ) - ->setHelp(<<setName('orm:schema-tool:drop') + ->setDescription('Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output') + ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.') + ->addOption('force', 'f', InputOption::VALUE_NONE, "Don't ask for the deletion of the database, but force the operation to run.") + ->addOption('full-database', null, InputOption::VALUE_NONE, 'Instead of using the Class Metadata to detect the database table schema, drop ALL assets that the database contains.') + ->setHelp(<<setFilterSchemaAssetsExpression(\$regexp); EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index 6ba2e41f8..39df55d96 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -19,10 +19,10 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to generate the SQL needed to update the database schema to match @@ -48,30 +48,12 @@ class UpdateCommand extends AbstractCommand */ protected function configure() { - $this - ->setName($this->name) - ->setDescription( - 'Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.' - ) - ->setDefinition( - [ - new InputOption( - 'complete', null, InputOption::VALUE_NONE, - 'If defined, all assets of the database which are not relevant to the current metadata will be dropped.' - ), - - new InputOption( - 'dump-sql', null, InputOption::VALUE_NONE, - 'Dumps the generated SQL statements to the screen (does not execute them).' - ), - new InputOption( - 'force', 'f', InputOption::VALUE_NONE, - 'Causes the generated SQL statements to be physically executed against your database.' - ), - ] - ); - - $this->setHelp(<<setName($this->name) + ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata') + ->addOption('complete', null, InputOption::VALUE_NONE, 'If defined, all assets of the database which are not relevant to the current metadata will be dropped.') + ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Dumps the generated SQL statements to the screen (does not execute them).') + ->addOption('force', 'f', InputOption::VALUE_NONE, 'Causes the generated SQL statements to be physically executed against your database.') + ->setHelp(<<%command.name% command generates the SQL needed to synchronize the database schema with the current mapping metadata of the default entity manager. @@ -101,7 +83,7 @@ on a global level: \$config->setFilterSchemaAssetsExpression(\$regexp); EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php index 57b16fc1c..f9acda547 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php @@ -19,11 +19,11 @@ namespace Doctrine\ORM\Tools\Console\Command; +use Doctrine\ORM\Tools\SchemaValidator; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\ORM\Tools\SchemaValidator; /** * Command to validate that the current mapping is valid. @@ -43,26 +43,11 @@ class ValidateSchemaCommand extends Command */ protected function configure() { - $this - ->setName('orm:validate-schema') - ->setDescription('Validate the mapping files.') - ->addOption( - 'skip-mapping', - null, - InputOption::VALUE_NONE, - 'Skip the mapping validation check' - ) - ->addOption( - 'skip-sync', - null, - InputOption::VALUE_NONE, - 'Skip checking if the mapping is in sync with the database' - ) - ->setHelp( - <<setName('orm:validate-schema') + ->setDescription('Validate the mapping files') + ->addOption('skip-mapping', null, InputOption::VALUE_NONE, 'Skip the mapping validation check') + ->addOption('skip-sync', null, InputOption::VALUE_NONE, 'Skip checking if the mapping is in sync with the database') + ->setHelp('Validate that the mapping files are correct and in sync with the database.'); } /**