1
0
mirror of synced 2025-02-02 21:41:45 +03:00

Use addOption()/addArgument() to configure commands

In order to simplify and standardise the definition of the commands.
This commit is contained in:
Oskar Stark 2017-11-23 11:18:08 +01:00 committed by Luís Cobucci
parent ba32237e2b
commit 214dc9896b
No known key found for this signature in database
GPG Key ID: EC61C5F01750ED3C
20 changed files with 206 additions and 448 deletions

View File

@ -19,13 +19,13 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; 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\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\ORM\Cache;
/** /**
* Command to clear a collection cache region. * Command to clear a collection cache region.
@ -40,17 +40,14 @@ class CollectionRegionCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:clear-cache:region:collection')
->setName('orm:clear-cache:region:collection') ->setDescription('Clear a second-level cache collection region')
->setDescription('Clear a second-level cache collection region.')
->addArgument('owner-class', InputArgument::OPTIONAL, 'The owner entity name.') ->addArgument('owner-class', InputArgument::OPTIONAL, 'The owner entity name.')
->addArgument('association', InputArgument::OPTIONAL, 'The association collection name.') ->addArgument('association', InputArgument::OPTIONAL, 'The association collection name.')
->addArgument('owner-id', InputArgument::OPTIONAL, 'The owner identifier.') ->addArgument('owner-id', InputArgument::OPTIONAL, 'The owner identifier.')
->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') ->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.'); ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.')
->setHelp(<<<EOT
$this->setHelp(<<<EOT
The <info>%command.name%</info> command is meant to clear a second-level cache collection regions for an associated Entity Manager. The <info>%command.name%</info> 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. It is possible to delete/invalidate all collection region, a specific collection region or flushes the cache provider.
@ -92,7 +89,7 @@ EOT
throw new \InvalidArgumentException('No second-level cache is configured on the given EntityManager.'); 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"'); throw new \InvalidArgumentException('Missing arguments "--owner-class" "--association"');
} }

View File

@ -19,13 +19,13 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; 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\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\ORM\Cache;
/** /**
* Command to clear a entity cache region. * Command to clear a entity cache region.
@ -40,16 +40,13 @@ class EntityRegionCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:clear-cache:region:entity')
->setName('orm:clear-cache:region:entity') ->setDescription('Clear a second-level cache entity region')
->setDescription('Clear a second-level cache entity region.')
->addArgument('entity-class', InputArgument::OPTIONAL, 'The entity name.') ->addArgument('entity-class', InputArgument::OPTIONAL, 'The entity name.')
->addArgument('entity-id', InputArgument::OPTIONAL, 'The entity identifier.') ->addArgument('entity-id', InputArgument::OPTIONAL, 'The entity identifier.')
->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') ->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.'); ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.')
->setHelp(<<<EOT
$this->setHelp(<<<EOT
The <info>%command.name%</info> command is meant to clear a second-level cache entity region for an associated Entity Manager. The <info>%command.name%</info> 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. It is possible to delete/invalidate all entity region, a specific entity region or flushes the cache provider.

View File

@ -19,12 +19,12 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; 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\ApcCache;
use Doctrine\Common\Cache\XcacheCache; 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. * Command to clear the metadata cache of the various cache drivers.
@ -43,19 +43,10 @@ class MetadataCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:clear-cache:metadata')
->setName('orm:clear-cache:metadata') ->setDescription('Clear all metadata cache of the various cache drivers')
->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.')
->setDefinition( ->setHelp(<<<EOT
[
new InputOption(
'flush', null, InputOption::VALUE_NONE,
'If defined, cache entries will be flushed instead of deleted/invalidated.'
)
]
);
$this->setHelp(<<<EOT
The <info>%command.name%</info> command is meant to clear the metadata cache of associated Entity Manager. The <info>%command.name%</info> 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 It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
instance completely. instance completely.

View File

@ -19,12 +19,12 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; 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\ApcCache;
use Doctrine\Common\Cache\XcacheCache; 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. * Command to clear the query cache of the various cache drivers.
@ -43,19 +43,10 @@ class QueryCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:clear-cache:query')
->setName('orm:clear-cache:query') ->setDescription('Clear all query cache of the various cache drivers')
->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.')
->setDefinition( ->setHelp(<<<EOT
[
new InputOption(
'flush', null, InputOption::VALUE_NONE,
'If defined, cache entries will be flushed instead of deleted/invalidated.'
)
]
);
$this->setHelp(<<<EOT
The <info>%command.name%</info> command is meant to clear the query cache of associated Entity Manager. The <info>%command.name%</info> 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 It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
instance completely. instance completely.

View File

@ -19,13 +19,13 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; 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\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\ORM\Cache;
/** /**
* Command to clear a query cache region. * Command to clear a query cache region.
@ -40,15 +40,12 @@ class QueryRegionCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:clear-cache:region:query')
->setName('orm:clear-cache:region:query') ->setDescription('Clear a second-level cache query region')
->setDescription('Clear a second-level cache query region.')
->addArgument('region-name', InputArgument::OPTIONAL, 'The query region to clear.') ->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('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.'); ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.')
->setHelp(<<<EOT
$this->setHelp(<<<EOT
The <info>%command.name%</info> command is meant to clear a second-level cache query region for an associated Entity Manager. The <info>%command.name%</info> 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. It is possible to delete/invalidate all query region, a specific query region or flushes the cache provider.

View File

@ -19,12 +19,12 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; 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\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; 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. * Command to clear the result cache of the various cache drivers.
@ -43,19 +43,10 @@ class ResultCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:clear-cache:result')
->setName('orm:clear-cache:result') ->setDescription('Clear all result cache of the various cache drivers')
->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.')
->setDefinition( ->setHelp(<<<EOT
[
new InputOption(
'flush', null, InputOption::VALUE_NONE,
'If defined, cache entries will be flushed instead of deleted/invalidated.'
)
]
);
$this->setHelp(<<<EOT
The <info>%command.name%</info> command is meant to clear the result cache of associated Entity Manager. The <info>%command.name%</info> 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 It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
instance completely. instance completely.

View File

@ -19,14 +19,14 @@
namespace Doctrine\ORM\Tools\Console\Command; 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\ConvertDoctrine1Schema;
use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\ORM\Tools\EntityGenerator;
use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command; 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. * Command to convert a Doctrine 1 schema to a Doctrine 2 mapping file.
@ -99,41 +99,16 @@ class ConvertDoctrine1SchemaCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:convert-d1-schema')
->setName('orm:convert-d1-schema')
->setAliases(['orm:convert:d1-schema']) ->setAliases(['orm:convert:d1-schema'])
->setDescription('Converts Doctrine 1.X schema into a Doctrine 2.X schema.') ->setDescription('Converts Doctrine 1.x schema into a Doctrine 2.x schema')
->setDefinition( ->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.')
new InputArgument( ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your Doctrine 2.X mapping information.')
'from-path', InputArgument::REQUIRED, 'The path of Doctrine 1.X schema 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.')
new InputArgument( ->addOption('num-spaces', null, InputOption::VALUE_OPTIONAL, 'Defines the number of indentation spaces', 4)
'to-type', InputArgument::REQUIRED, 'The destination Doctrine 2.X mapping type.' ->setHelp('Converts Doctrine 1.x schema into a Doctrine 2.x schema.');
),
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(<<<EOT
Converts Doctrine 1.X schema into a Doctrine 2.X schema.
EOT
);
} }
/** /**

View File

@ -19,16 +19,16 @@
namespace Doctrine\ORM\Tools\Console\Command; 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 Doctrine\ORM\Mapping\Driver\DatabaseDriver;
use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\Tools\Console\MetadataFilter;
use Symfony\Component\Console\Input\InputInterface; 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\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. * Command to convert your mapping information between the various formats.
@ -47,44 +47,17 @@ class ConvertMappingCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:convert-mapping')
->setName('orm:convert-mapping')
->setAliases(['orm:convert:mapping']) ->setAliases(['orm:convert:mapping'])
->setDescription('Convert mapping information between supported formats.') ->setDescription('Convert mapping information between supported formats')
->setDefinition( ->addArgument('to-type', InputArgument::REQUIRED, 'The mapping type to be converted.')
[ ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your entities classes.')
new InputOption( ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.')
'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force to overwrite existing mapping files.')
'A string pattern used to match entities that should be processed.' ->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.')
new InputArgument( ->addOption('num-spaces', null, InputOption::VALUE_OPTIONAL, 'Defines the number of indentation spaces', 4)
'to-type', InputArgument::REQUIRED, 'The mapping type to be converted.' ->addOption('namespace', null, InputOption::VALUE_OPTIONAL, 'Defines a namespace for the generated entity classes, if converted from database.')
),
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(<<<EOT ->setHelp(<<<EOT
Convert mapping information between supported formats. Convert mapping information between supported formats.

View File

@ -20,8 +20,8 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Throwable; use Throwable;
@ -43,21 +43,10 @@ class EnsureProductionSettingsCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:ensure-production-settings')
->setName('orm:ensure-production-settings') ->setDescription('Verify that Doctrine is properly configured for a production environment')
->setDescription('Verify that Doctrine is properly configured for a production environment.') ->addOption('complete', null, InputOption::VALUE_NONE, 'Flag to also inspect database connection existence.')
->setDefinition( ->setHelp('Verify that Doctrine is properly configured for a production environment.');
[
new InputOption(
'complete', null, InputOption::VALUE_NONE,
'Flag to also inspect database connection existence.'
)
]
)
->setHelp(<<<EOT
Verify that Doctrine is properly configured for a production environment.
EOT
);
} }
/** /**

View File

@ -19,14 +19,14 @@
namespace Doctrine\ORM\Tools\Console\Command; 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\Console\MetadataFilter;
use Doctrine\ORM\Tools\EntityGenerator;
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\Tools\EntityGenerator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command; 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. * Command to generate entity classes and method stubs from your mapping information.
@ -45,49 +45,18 @@ class GenerateEntitiesCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:generate-entities')
->setName('orm:generate-entities')
->setAliases(['orm:generate:entities']) ->setAliases(['orm:generate:entities'])
->setDescription('Generate entity classes and method stubs from your mapping information.') ->setDescription('Generate entity classes and method stubs from your mapping information')
->setDefinition( ->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.')
new InputOption( ->addOption('generate-annotations', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should generate annotation metadata on entities.', false)
'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, ->addOption('generate-methods', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should generate stub methods on entities.', true)
'A string pattern used to match entities that should be processed.' ->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)
new InputArgument( ->addOption('extend', null, InputOption::VALUE_REQUIRED, 'Defines a base class to be extended by generated entity classes.')
'dest-path', InputArgument::REQUIRED, 'The path to generate your 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.')
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(<<<EOT ->setHelp(<<<EOT
Generate entity classes and method stubs from your mapping information. Generate entity classes and method stubs from your mapping information.
@ -139,7 +108,6 @@ EOT
} }
if (count($metadatas)) { if (count($metadatas)) {
// Create EntityGenerator
$entityGenerator = new EntityGenerator(); $entityGenerator = new EntityGenerator();
$entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations')); $entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));

View File

@ -19,12 +19,13 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Input\InputOption;
use Doctrine\ORM\Tools\Console\MetadataFilter; 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\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. * Command to (re)generate the proxy classes used by doctrine.
@ -43,26 +44,12 @@ class GenerateProxiesCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:generate-proxies')
->setName('orm:generate-proxies')
->setAliases(['orm:generate:proxies']) ->setAliases(['orm:generate:proxies'])
->setDescription('Generates proxy classes for entity classes.') ->setDescription('Generates proxy classes for entity classes')
->setDefinition( ->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.')
new InputOption( ->setHelp('Generates proxy classes for entity classes.');
'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(<<<EOT
Generates proxy classes for entity classes.
EOT
);
} }
/** /**
@ -70,6 +57,7 @@ EOT
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
/** @var EntityManagerInterface $em */
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$metadatas = $em->getMetadataFactory()->getAllMetadata(); $metadatas = $em->getMetadataFactory()->getAllMetadata();

View File

@ -19,13 +19,13 @@
namespace Doctrine\ORM\Tools\Console\Command; 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\Console\MetadataFilter;
use Doctrine\ORM\Tools\EntityRepositoryGenerator; 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\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. * Command to generate repository classes for mapping information.
@ -44,25 +44,12 @@ class GenerateRepositoriesCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:generate-repositories')
->setName('orm:generate-repositories')
->setAliases(['orm:generate:repositories']) ->setAliases(['orm:generate:repositories'])
->setDescription('Generate repository classes from your mapping information.') ->setDescription('Generate repository classes from your mapping information')
->setDefinition( ->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.')
new InputOption( ->setHelp('Generate repository classes from your mapping information.');
'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(<<<EOT
Generate repository classes from your mapping information.
EOT
);
} }
/** /**

View File

@ -20,9 +20,9 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\MappingException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
/** /**
* Show information about mapped entities. * Show information about mapped entities.
@ -38,8 +38,7 @@ class InfoCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:info')
->setName('orm:info')
->setDescription('Show basic information about all mapped entities') ->setDescription('Show basic information about all mapped entities')
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>%command.name%</info> shows basic information about which The <info>%command.name%</info> shows basic information about which
@ -61,7 +60,7 @@ EOT
->getMetadataDriverImpl() ->getMetadataDriverImpl()
->getAllClassNames(); ->getAllClassNames();
if (!$entityClassNames) { if ( ! $entityClassNames) {
throw new \Exception( throw new \Exception(
'You do not have any mapped Doctrine ORM entities according to the current configuration. '. '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.' 'If you have entities or mapping files you should check your mapping configuration for errors.'

View File

@ -41,8 +41,7 @@ final class MappingDescribeCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:mapping:describe')
->setName('orm:mapping:describe')
->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity') ->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity')
->setDescription('Display information about mapped objects') ->setDescription('Display information about mapped objects')
->setHelp(<<<EOT ->setHelp(<<<EOT
@ -138,8 +137,7 @@ EOT
*/ */
private function getMappedEntities(EntityManagerInterface $entityManager) private function getMappedEntities(EntityManagerInterface $entityManager)
{ {
$entityClassNames = $entityManager $entityClassNames = $entityManager->getConfiguration()
->getConfiguration()
->getMetadataDriverImpl() ->getMetadataDriverImpl()
->getAllClassNames(); ->getAllClassNames();

View File

@ -19,12 +19,12 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Doctrine\Common\Util\Debug;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Util\Debug;
/** /**
* Command to execute DQL queries in a given EntityManager. * Command to execute DQL queries in a given EntityManager.
@ -43,39 +43,15 @@ class RunDqlCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:run-dql')
->setName('orm:run-dql') ->setDescription('Executes arbitrary DQL directly from the command line')
->setDescription('Executes arbitrary DQL directly from the command line.') ->addArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.')
->setDefinition( ->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.')
new InputArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.'), ->addOption('max-result', null, InputOption::VALUE_REQUIRED, 'The maximum number of results in the result set.')
new InputOption( ->addOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of Entity graph.', 7)
'hydrate', null, InputOption::VALUE_REQUIRED, ->addOption('show-sql', null, InputOption::VALUE_NONE, 'Dump generated SQL instead of executing query')
'Hydration mode of result set. Should be either: object, array, scalar or single-scalar.', ->setHelp('Executes arbitrary DQL directly from the command line.');
'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(<<<EOT
Executes arbitrary DQL directly from the command line.
EOT
);
} }
/** /**
@ -87,13 +63,13 @@ EOT
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
if (($dql = $input->getArgument('dql')) === null) { 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'); $depth = $input->getOption('depth');
if ( ! is_numeric($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'); $hydrationModeName = $input->getOption('hydrate');
@ -109,7 +85,7 @@ EOT
if (($firstResult = $input->getOption('first-result')) !== null) { if (($firstResult = $input->getOption('first-result')) !== null) {
if ( ! is_numeric($firstResult)) { 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); $query->setFirstResult((int) $firstResult);
@ -117,7 +93,7 @@ EOT
if (($maxResult = $input->getOption('max-result')) !== null) { if (($maxResult = $input->getOption('max-result')) !== null) {
if ( ! is_numeric($maxResult)) { 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); $query->setMaxResults((int) $maxResult);

View File

@ -19,10 +19,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; 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\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
use Doctrine\ORM\Tools\SchemaTool;
/** /**
* Base class for CreateCommand, DropCommand and UpdateCommand. * Base class for CreateCommand, DropCommand and UpdateCommand.

View File

@ -19,10 +19,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; 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 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. * Command to create the database schema for a set of classes based on their mappings.
@ -41,19 +41,9 @@ class CreateCommand extends AbstractCommand
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:schema-tool:create')
->setName('orm:schema-tool:create') ->setDescription('Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output')
->setDescription( ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.')
'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(<<<EOT ->setHelp(<<<EOT
Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output. Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.

View File

@ -19,10 +19,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; 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 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. * Command to drop the database schema for a set of classes based on their mappings.
@ -41,27 +41,11 @@ class DropCommand extends AbstractCommand
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:schema-tool:drop')
->setName('orm:schema-tool:drop') ->setDescription('Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output')
->setDescription( ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.')
'Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output.' ->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.')
->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(<<<EOT ->setHelp(<<<EOT
Processes the schema and either drop the database schema of EntityManager Storage Connection or generate the SQL output. Processes the schema and either drop the database schema of EntityManager Storage Connection or generate the SQL output.
Beware that the complete database is dropped by this command, even tables that are not relevant to your metadata model. Beware that the complete database is dropped by this command, even tables that are not relevant to your metadata model.

View File

@ -19,10 +19,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; 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 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 * Command to generate the SQL needed to update the database schema to match
@ -48,30 +48,12 @@ class UpdateCommand extends AbstractCommand
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName($this->name)
->setName($this->name) ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata')
->setDescription( ->addOption('complete', null, InputOption::VALUE_NONE, 'If defined, all assets of the database which are not relevant to the current metadata will be dropped.')
'Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.' ->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.')
->setDefinition( ->setHelp(<<<EOT
[
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(<<<EOT
The <info>%command.name%</info> command generates the SQL needed to The <info>%command.name%</info> command generates the SQL needed to
synchronize the database schema with the current mapping metadata of the synchronize the database schema with the current mapping metadata of the
default entity manager. default entity manager.

View File

@ -19,11 +19,11 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Doctrine\ORM\Tools\SchemaValidator;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\SchemaValidator;
/** /**
* Command to validate that the current mapping is valid. * Command to validate that the current mapping is valid.
@ -43,26 +43,11 @@ class ValidateSchemaCommand extends Command
*/ */
protected function configure() protected function configure()
{ {
$this $this->setName('orm:validate-schema')
->setName('orm:validate-schema') ->setDescription('Validate the mapping files')
->setDescription('Validate the mapping files.') ->addOption('skip-mapping', null, InputOption::VALUE_NONE, 'Skip the mapping validation check')
->addOption( ->addOption('skip-sync', null, InputOption::VALUE_NONE, 'Skip checking if the mapping is in sync with the database')
'skip-mapping', ->setHelp('Validate that the mapping files are correct and in sync with the database.');
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(
<<<EOT
'Validate that the mapping files are correct and in sync with the database.'
EOT
);
} }
/** /**