8000 Took into account @cordoval's feedback · symfony/symfony-docs@e8b3320 · GitHub
[go: up one dir, main page]

Skip to content

Commit e8b3320

Browse files
author
Loïc Chardonnet
committed
Took into account @cordoval's feedback
1 parent 11bfe50 commit e8b3320

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

components/console/commands_as_services.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ the ``ContainerAwareCommand`` interface, Symfony will even inject the container.
1414
While making life easier, this default implementation has some drawbacks in some
1515
situations:
1616

17-
* What if you want your command to be defined elsewhere than in the ``Command``
18-
directory?
19-
* what if you want to conditionally register your command, depending on the
20-
current environment or on the availability of some dependencies?
21-
* what if you need to access dependencies before the ``setContainer()`` is
22-
called (for example in the ``configure()`` method)?
23-
* what if you want to reuse a command many times, but with different
24-
dependencies or parameters?
17+
* Define the command elsewhere than in the ``Command`` directory;
18+
* Conditionally register your command, depending on the current environment or
19+
on the availability of some dependencies;
20+
* Access dependencies before the ``setContainer()`` is called (for example in
21+
the ``configure()`` method);
22+
* Reuse a command many times, but with different dependencies or parameters
2523

2624
To solve those problems, you can register your command as a service by simply
2725
defining it with the ``console.command`` tag:
@@ -73,7 +71,7 @@ pass one of the following as the 5th argument of ``addOption()``:
7371

7472
With a ``ContainerAwareCommand`` you wouldn't be able to retrieve the
7573
configuration parameter, because the ``configure()`` method is called in the
76-
constructor. The only solution is to inject them through it::
74+
constructor. The only solution is to inject them::
7775

7876
// src/Acme/DemoBundle/Command/GreetCommand.php
7977
namespace Acme\DemoBundle\Command;
@@ -114,6 +112,6 @@ constructor. The only solution is to inject them through it::
114112

115113
.. caution::
116114

117-
When running the console, every commands are instanciated, which means every
118-
``configure()`` methods are called. Be careful with database queries, as
119-
this could impact performances.
115+
When running the console, every command is instantiated, which means every
116+
``configure()`` method is called. Be careful with database queries, as
117+
they could impact performance.

0 commit comments

Comments
 (0)
0