diff --git a/components/console/changing_default_command.rst b/components/console/changing_default_command.rst index c9d5a1fe1e8..b5baf00c022 100644 --- a/components/console/changing_default_command.rst +++ b/components/console/changing_default_command.rst @@ -16,10 +16,11 @@ name to the ``setDefaultCommand()`` method:: class HelloWorldCommand extends Command { + protected static $defaultName = 'hello:world'; + protected function configure() { - $this->setName('hello:world') - ->setDescription('Outputs \'Hello World\''); + $this->setDescription('Outputs "Hello World"'); } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/components/console/console_arguments.rst b/components/console/console_arguments.rst index 8799cb0cc7f..79f5c6c1f4c 100644 --- a/components/console/console_arguments.rst +++ b/components/console/console_arguments.rst @@ -23,10 +23,11 @@ Have a look at the following command that has three options:: class DemoArgsCommand extends Command { + protected static $defaultName = 'demo:args'; + protected function configure() { $this - ->setName('demo:args') ->setDescription('Describe args behaviors') ->setDefinition( new InputDefinition([ diff --git a/components/console/logger.rst b/components/console/logger.rst index 642f791a4d3..528b7df3f2c 100644 --- a/components/console/logger.rst +++ b/components/console/logger.rst @@ -44,10 +44,11 @@ You can rely on the logger to use this dependency inside a command:: class MyCommand extends Command { + protected static $defaultName = 'my:command'; + protected function configure() { $this - ->setName('my:command') ->setDescription( 'Use an external dependency requiring a PSR-3 logger' ) diff --git a/console/commands_as_services.rst b/console/commands_as_services.rst index f5ccc02d00b..30ba7265f23 100644 --- a/console/commands_as_services.rst +++ b/console/commands_as_services.rst @@ -35,6 +35,7 @@ For example, suppose you want to log something from within your command:: class SunshineCommand extends Command { + protected static $defaultName = 'app:sunshine'; private $logger; public function __construct(LoggerInterface $logger) @@ -48,7 +49,6 @@ For example, suppose you want to log something from within your command:: protected function configure() { $this - ->setName('app:sunshine') ->setDescription('Good morning!'); } diff --git a/console/hide_commands.rst b/console/hide_commands.rst index d7c9b011e94..4a747b23245 100644 --- a/console/hide_commands.rst +++ b/console/hide_commands.rst @@ -18,10 +18,11 @@ In those cases, you can define the command as **hidden** by setting the class LegacyCommand extends Command { + protected static $defaultName = 'app:legacy'; + protected function configure() { $this - ->setName('app:legacy') ->setHidden(true) // ... ;