Skip to content

Commit 89fdff3

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [DependencyInjection] Minor improvement of service tag description Rewords and tweaks [Console] Document lazy command via description
2 parents d72295a + f5a666f commit 89fdff3

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

console.rst

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,38 @@ Configuring the Command
7070
You can optionally define a description, help message and the
7171
:doc:`input options and arguments </console/input>`::
7272

73+
// ...
74+
// the command description shown when running "php bin/console list"
75+
protected static $defaultDescription = 'Creates a new user.';
76+
7377
// ...
7478
protected function configure(): void
7579
{
7680
$this
77-
// the short description shown while running "php bin/console list"
78-
->setDescription('Creates a new user.')
81+
// If you don't like using the $defaultDescription static property,
82+
// you can also define the short description using this method:
83+
// ->setDescription('...')
7984

80-
// the full command description shown when running the command with
81-
// the "--help" option
85+
// the command help shown when running the command with the "--help" option
8286
->setHelp('This command allows you to create a user...')
8387
;
8488
}
8589

90+
Defining the ``$defaultDescription`` static property instead of using the
91+
``setDescription()`` method allows to get the command description without
92+
instantiating its class. This makes the ``php bin/console list`` command run
93+
much faster.
94+
95+
If you want to always run the ``list`` command fast, add the ``--short`` option
96+
to it (``php bin/console list --short``). This will avoid instantiating command
97+
classes, but it won't show any description for commands that use the
98+
``setDescription()`` method instead of the static property.
99+
100+
.. versionadded:: 5.3
101+
102+
The ``$defaultDescription`` static property and the ``--short`` option
103+
were introduced in Symfony 5.3.
104+
86105
The ``configure()`` method is called automatically at the end of the command
87106
constructor. If your command defines its own constructor, set the properties
88107
first and then call to the parent constructor, to make those properties

service_container/tags.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ application handlers::
598598
Tagged Services with Priority
599599
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
600600

601-
The tagged services can be prioritized using the ``priority`` attribute.
602-
The priority is a positive or negative integer. The higher the number,
603-
the earlier the tagged service will be located in the collection:
601+
The tagged services can be prioritized using the ``priority`` attribute. The
602+
priority is a positive or negative integer that defaults to ``0``. The higher
603+
the number, the earlier the tagged service will be located in the collection:
604604

605605
.. configuration-block::
606606

0 commit comments

Comments
 (0)