Skip to content

Commit bd00116

Browse files
committed
[DependencyInjection] Clarify the #[Target] attribute 2
1 parent b8d488d commit bd00116

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

service_container/autowiring.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,21 @@ decorrelated of any implementation name (like shown in the example above).
556556
The ``#[Target]`` attribute only accepts the name of the argument used in the named
557557
alias, it **does not** accept service ids or service aliases.
558558

559+
You can get a list of named autowirable alias by running the ``debug:autowiring`` command::
560+
561+
.. code-block:: terminal
562+
563+
$ bin/console debug:autowiring TransformerInterface
564+
565+
Autowirable Types
566+
=================
567+
568+
The following classes & interfaces can be used as type-hints when autowiring:
569+
(only showing classes/interfaces matching TransformerInterface)
570+
571+
App\Util\TransformerInterface - alias:App\Util\Rot13Transformer
572+
App\Util\TransformerInterface $shoutyTransformer - alias:App\Util\UppercaseTransformer
573+
559574
Suppose you want to inject the ``App\Util\UppercaseTransformer`` service. You would use
560575
the ``#[Target]`` attribute by passing the name of the ``$shoutyTransformer`` argument::
561576

0 commit comments

Comments
 (0)