Skip to content

[Console] Always use lazy commands #12017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/console/changing_default_command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion components/console/console_arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
3 changes: 2 additions & 1 deletion components/console/logger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Expand Down
2 changes: 1 addition & 1 deletion console/commands_as_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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!');
}

Expand Down
3 changes: 2 additions & 1 deletion console/hide_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// ...
;
Expand Down