Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 67abb80

Browse filesBrowse files
committed
feature #23887 [Console] Allow commands to provide a default name for compile time registration (chalasr, nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Console] Allow commands to provide a default name for compile time registration | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23796 | License | MIT | Doc PR | symfony/symfony-docs#8147 Commits ------- eda7d42 [Console] Add protected static $defaultName to set the default name of a Command 5d9ae6b [Console] Allow commands to provide a default name for compile time registration
2 parents 481e31c + eda7d42 commit 67abb80
Copy full SHA for 67abb80

32 files changed

+130
-45
lines changed

‎src/Symfony/Bridge/Twig/Command/DebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/DebugCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*/
2727
class DebugCommand extends Command
2828
{
29+
protected static $defaultName = 'debug:twig';
30+
2931
private $twig;
3032

3133
/**
@@ -66,7 +68,6 @@ protected function getTwigEnvironment()
6668
protected function configure()
6769
{
6870
$this
69-
->setName('debug:twig')
7071
->setDefinition(array(
7172
new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all entries matching this filter'),
7273
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),

‎src/Symfony/Bridge/Twig/Command/LintCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/LintCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
*/
3232
class LintCommand extends Command
3333
{
34+
protected static $defaultName = 'lint:twig';
35+
3436
private $twig;
3537

3638
/**
@@ -71,7 +73,6 @@ protected function getTwigEnvironment()
7173
protected function configure()
7274
{
7375
$this
74-
->setName('lint:twig')
7576
->setDescription('Lints a template and outputs encountered errors')
7677
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
7778
->addArgument('filename', InputArgument::IS_ARRAY)

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
"symfony/security": "~2.8|~3.0|~4.0",
3434
"symfony/security-acl": "~2.8|~3.0",
3535
"symfony/stopwatch": "~2.8|~3.0|~4.0",
36-
"symfony/console": "~2.8|~3.0|~4.0",
36+
"symfony/console": "~3.4|~4.0",
3737
"symfony/var-dumper": "~2.8.10|~3.1.4|~3.2|~4.0",
3838
"symfony/expression-language": "~2.8|~3.0|~4.0",
3939
"symfony/web-link": "~3.3|~4.0"
4040
},
4141
"conflict": {
42-
"symfony/form": "<3.2.10|~3.3,<3.3.3"
42+
"symfony/form": "<3.2.10|~3.3,<3.3.3",
43+
"symfony/console": "<3.4"
4344
},
4445
"suggest": {
4546
"symfony/finder": "",

‎src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@
2828
*/
2929
class AboutCommand extends ContainerAwareCommand
3030
{
31+
protected static $defaultName = 'about';
32+
3133
/**
3234
* {@inheritdoc}
3335
*/
3436
protected function configure()
3537
{
36-
$this
37-
->setName('about')
38-
->setDescription('Displays information about the current project')
39-
;
38+
$this->setDescription('Displays information about the current project');
4039
}
4140

4241
/**

‎src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class AssetsInstallCommand extends ContainerAwareCommand
3535
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
3636
const METHOD_RELATIVE_SYMLINK = 'relative symlink';
3737

38+
protected static $defaultName = 'assets:install';
39+
3840
private $filesystem;
3941

4042
/**
@@ -61,7 +63,6 @@ public function __construct($filesystem = null)
6163
protected function configure()
6264
{
6365
$this
64-
->setName('assets:install')
6566
->setDefinition(array(
6667
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'),
6768
))

‎src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
class CacheClearCommand extends ContainerAwareCommand
3434
{
35+
protected static $defaultName = 'cache:clear';
36+
3537
private $cacheClearer;
3638
private $filesystem;
3739
private $warning;
@@ -62,7 +64,6 @@ public function __construct($cacheClearer = null, Filesystem $filesystem = null)
6264
protected function configure()
6365
{
6466
$this
65-
->setName('cache:clear')
6667
->setDefinition(array(
6768
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
6869
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),

‎src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
final class CachePoolClearCommand extends ContainerAwareCommand
2727
{
28+
protected static $defaultName = 'cache:pool:clear';
29+
2830
private $poolClearer;
2931

3032
/**
@@ -51,7 +53,6 @@ public function __construct($poolClearer = null)
5153
protected function configure()
5254
{
5355
$this
54-
->setName('cache:pool:clear')
5556
->setDefinition(array(
5657
new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'),
5758
))

‎src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
final class CachePoolPruneCommand extends Command
2626
{
27+
protected static $defaultName = 'cache:pool:prune';
28+
2729
private $pools;
2830

2931
/**
@@ -42,7 +44,6 @@ public function __construct($pools)
4244
protected function configure()
4345
{
4446
$this
45-
->setName('cache:pool:prune')
4647
->setDescription('Prune cache pools')
4748
->setHelp(<<<'EOF'
4849
The <info>%command.name%</info> command deletes all expired items from all pruneable pools.

‎src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*/
2727
class CacheWarmupCommand extends ContainerAwareCommand
2828
{
29+
protected static $defaultName = 'cache:warmup';
30+
2931
private $cacheWarmer;
3032

3133
/**
@@ -52,7 +54,6 @@ public function __construct($cacheWarmer = null)
5254
protected function configure()
5355
{
5456
$this
55-
->setName('cache:warmup')
5657
->setDefinition(array(
5758
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
5859
))

‎src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@
2828
*/
2929
class ConfigDebugCommand extends AbstractConfigCommand
3030
{
31+
protected static $defaultName = 'debug:config';
32+
3133
/**
3234
* {@inheritdoc}
3335
*/
3436
protected function configure()
3537
{
3638
$this
37-
->setName('debug:config')
3839
->setDefinition(array(
3940
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
4041
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),

‎src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
*/
3131
class ConfigDumpReferenceCommand extends AbstractConfigCommand
3232
{
33+
protected static $defaultName = 'config:dump-reference';
34+
3335
/**
3436
* {@inheritdoc}
3537
*/
3638
protected function configure()
3739
{
3840
$this
39-
->setName('config:dump-reference')
4041
->setDefinition(array(
4142
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'),
4243
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),

‎src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
class ContainerDebugCommand extends ContainerAwareCommand
3434
{
35+
protected static $defaultName = 'debug:container';
36+
3537
/**
3638
* @var ContainerBuilder|null
3739
*/
@@ -43,7 +45,6 @@ class ContainerDebugCommand extends ContainerAwareCommand
4345
protected function configure()
4446
{
4547
$this
46-
->setName('debug:container')
4748
->setDefinition(array(
4849
new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'),
4950
new InputOption('show-private', null, InputOption::VALUE_NONE, 'Used to show public *and* private services'),

‎src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
class EventDispatcherDebugCommand extends ContainerAwareCommand
3030
{
31+
protected static $defaultName = 'debug:event-dispatcher';
3132
private $dispatcher;
3233

3334
/**
@@ -54,7 +55,6 @@ public function __construct($dispatcher = null)
5455
protected function configure()
5556
{
5657
$this
57-
->setName('debug:event-dispatcher')
5858
->setDefinition(array(
5959
new InputArgument('event', InputArgument::OPTIONAL, 'An event name'),
6060
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),

‎src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333
class RouterDebugCommand extends ContainerAwareCommand
3434
{
35+
protected static $defaultName = 'debug:router';
3536
private $router;
3637

3738
/**
@@ -79,7 +80,6 @@ public function isEnabled()
7980
protected function configure()
8081
{
8182
$this
82-
->setName('debug:router')
8383
->setDefinition(array(
8484
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
8585
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),

‎src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
class RouterMatchCommand extends ContainerAwareCommand
3131
{
32+
protected static $defaultName = 'router:match';
33+
3234
private $router;
3335

3436
/**
@@ -76,7 +78,6 @@ public function isEnabled()
7678
protected function configure()
7779
{
7880
$this
79-
->setName('router:match')
8081
->setDefinition(array(
8182
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
8283
new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method'),

‎src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class TranslationDebugCommand extends ContainerAwareCommand
4040
const MESSAGE_UNUSED = 1;
4141
const MESSAGE_EQUALS_FALLBACK = 2;
4242

43+
protected static $defaultName = 'debug:translation';
44+
4345
private $translator;
4446
private $loader;
4547
private $extractor;
@@ -72,7 +74,6 @@ public function __construct($translator = null, TranslationLoader $loader = null
7274
protected function configure()
7375
{
7476
$this
75-
->setName('debug:translation')
7677
->setDefinition(array(
7778
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
7879
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'),

‎src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
*/
3434
class TranslationUpdateCommand extends ContainerAwareCommand
3535
{
36+
protected static $defaultName = 'translation:update';
37+
3638
private $writer;
3739
private $loader;
3840
private $extractor;
@@ -68,7 +70,6 @@ public function __construct($writer = null, TranslationLoader $loader = null, Ex
6870
protected function configure()
6971
{
7072
$this
71-
->setName('translation:update')
7273
->setDefinition(array(
7374
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
7475
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'),

‎src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class WorkflowDumpCommand extends ContainerAwareCommand
2727
{
28+
protected static $defaultName = 'workflow:dump';
29+
2830
/**
2931
* {@inheritdoc}
3032
*
@@ -41,7 +43,6 @@ public function isEnabled()
4143
protected function configure()
4244
{
4345
$this
44-
->setName('workflow:dump')
4546
->setDefinition(array(
4647
new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'),
4748
new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'),

‎src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
class XliffLintCommand extends BaseLintCommand
2626
{
27+
protected static $defaultName = 'lint:xliff';
28+
2729
public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
2830
{
2931
if (func_num_args()) {

‎src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class YamlLintCommand extends BaseLintCommand
2525
{
26+
protected static $defaultName = 'lint:yaml';
27+
2628
public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
2729
{
2830
if (func_num_args()) {

‎src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*/
2828
class InitAclCommand extends ContainerAwareCommand
2929
{
30+
protected static $defaultName = 'init:acl';
31+
3032
private $connection;
3133
private $schema;
3234

@@ -70,7 +72,6 @@ public function isEnabled()
7072
protected function configure()
7173
{
7274
$this
73-
->setName('init:acl')
7475
->setDescription('Mounts ACL tables in the database')
7576
->setHelp(<<<'EOF'
7677
The <info>%command.name%</info> command mounts ACL tables in the database.

‎src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
class SetAclCommand extends ContainerAwareCommand
3434
{
35+
protected static $defaultName = 'acl:set';
36+
3537
private $provider;
3638

3739
/**
@@ -80,7 +82,6 @@ public function isEnabled()
8082
protected function configure()
8183
{
8284
$this
83-
->setName('acl:set')
8485
->setDescription('Sets ACL for objects')
8586
->setHelp(<<<EOF
8687
The <info>%command.name%</info> command sets ACL.

‎src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\Console\Output\OutputInterface;
2020
use Symfony\Component\Console\Question\Question;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
2322
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
2423
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
2524
use Symfony\Component\Security\Core\User\User;
@@ -33,6 +32,8 @@
3332
*/
3433
class UserPasswordEncoderCommand extends ContainerAwareCommand
3534
{
35+
protected static $defaultName = 'security:encode-password';
36+
3637
private $encoderFactory;
3738
private $userClasses;
3839

@@ -54,7 +55,6 @@ public function __construct(EncoderFactoryInterface $encoderFactory = null, arra
5455
protected function configure()
5556
{
5657
$this
57-
->setName('security:encode-password')
5858
->setDescription('Encodes a password.')
5959
->addArgument('password', InputArgument::OPTIONAL, 'The plain password to encode.')
6060
->addArgument('user-class', InputArgument::OPTIONAL, 'The User entity class path associated with the encoder used to encode the password.')

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* file that was distributed with this source code.
2121
*/
2222
use Symfony\Bundle\FrameworkBundle\Console\Application;
23-
use Symfony\Bundle\SecurityBundle\Command\InitAclCommand;
2423
use Symfony\Bundle\SecurityBundle\Command\SetAclCommand;
2524
use Symfony\Component\Console\Tester\CommandTester;
2625
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
@@ -170,7 +169,6 @@ private function getApplication()
170169
$kernel->boot();
171170

172171
$application = new Application($kernel);
173-
$application->add(new InitAclCommand($kernel->getContainer()->get('security.acl.dbal.connection'), $kernel->getContainer()->get('security.acl.dbal.schema')));
174172

175173
$initAclCommand = $application->find('init:acl');
176174
$initAclCommandTester = new CommandTester($initAclCommand);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.