Skip to content

Commit e564caa

Browse files
committed
minor symfony#12017 [Console] Always use lazy commands (javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- [Console] Always use lazy commands Fixes symfony#8843. Commits ------- 1e50fcf [Console] Always use lazy commands
2 parents 890c823 + 1e50fcf commit e564caa

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

components/console/changing_default_command.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ name to the ``setDefaultCommand()`` method::
1616

1717
class HelloWorldCommand extends Command
1818
{
19+
protected static $defaultName = 'hello:world';
20+
1921
protected function configure()
2022
{
21-
$this->setName('hello:world')
22-
->setDescription('Outputs \'Hello World\'');
23+
$this->setDescription('Outputs "Hello World"');
2324
}
2425

2526
protected function execute(InputInterface $input, OutputInterface $output)

components/console/console_arguments.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Have a look at the following command that has three options::
2323

2424
class DemoArgsCommand extends Command
2525
{
26+
protected static $defaultName = 'demo:args';
27+
2628
protected function configure()
2729
{
2830
$this
29-
->setName('demo:args')
3031
->setDescription('Describe args behaviors')
3132
->setDefinition(
3233
new InputDefinition([

components/console/logger.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ You can rely on the logger to use this dependency inside a command::
4444

4545
class MyCommand extends Command
4646
{
47+
protected static $defaultName = 'my:command';
48+
4749
protected function configure()
4850
{
4951
$this
50-
->setName('my:command')
5152
->setDescription(
5253
'Use an external dependency requiring a PSR-3 logger'
5354
)

console/commands_as_services.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ For example, suppose you want to log something from within your command::
3535

3636
class SunshineCommand extends Command
3737
{
38+
protected static $defaultName = 'app:sunshine';
3839
private $logger;
3940

4041
public function __construct(LoggerInterface $logger)
@@ -48,7 +49,6 @@ For example, suppose you want to log something from within your command::
4849
protected function configure()
4950
{
5051
$this
51-
->setName('app:sunshine')
5252
->setDescription('Good morning!');
5353
}
5454

console/hide_commands.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ In those cases, you can define the command as **hidden** by setting the
1818

1919
class LegacyCommand extends Command
2020
{
21+
protected static $defaultName = 'app:legacy';
22+
2123
protected function configure()
2224
{
2325
$this
24-
->setName('app:legacy')
2526
->setHidden(true)
2627
// ...
2728
;

0 commit comments

Comments
 (0)