Skip to content

Commit 32770b2

Browse files
committed
minor #18749 [DependencyInjection] Ref for autowiring alias (OskarStark)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Ref for autowiring alias Replaces * #17051 I had a lot of conflicts, because #17051 was against `4.4` branch, so I decided to recreate this PR. Commits ------- 6d0552c Ref for autowiring alias
2 parents 2f275d8 + 6d0552c commit 32770b2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

service_container.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,9 @@ admin email. In this case, each needs to have a unique service id:
12861286
In this case, *two* services are registered: ``site_update_manager.superadmin``
12871287
and ``site_update_manager.normal_users``. Thanks to the alias, if you type-hint
12881288
``SiteUpdateManager`` the first (``site_update_manager.superadmin``) will be passed.
1289-
If you want to pass the second, you'll need to :ref:`manually wire the service <services-wire-specific-service>`.
1289+
1290+
If you want to pass the second, you'll need to :ref:`manually wire the service <services-wire-specific-service>`
1291+
or to create a named ref:`autowiring alias <autowiring-alias>`.
12901292

12911293
.. caution::
12921294

service_container/autowiring.rst

+2
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ Additionally, you can define several named autowiring aliases if you want to use
423423
one implementation in some cases, and another implementation in some
424424
other cases.
425425

426+
.. _autowiring-alias:
427+
426428
For instance, you may want to use the ``Rot13Transformer``
427429
implementation by default when the ``TransformerInterface`` interface is
428430
type hinted, but use the ``UppercaseTransformer`` implementation in some

0 commit comments

Comments
 (0)