From b9a5ea4619eca7a6d0579e297b360a4ae8d65a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morel=20Se=CC=81bastien?= Date: Wed, 9 May 2018 22:09:58 -0700 Subject: [PATCH 1/2] Autowiring - Rephrase aliasing when multiple classes implement same interface --- service_container/autowiring.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 91a434dee5c..cf582ab763f 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -358,9 +358,11 @@ Suppose you create a second class - ``UppercaseTransformer`` that implements } If you register this as a service, you now have *two* services that implement the -``App\Util\TransformerInterface`` type. Symfony doesn't know which one should -be used for autowiring, so you need to choose one by creating an alias from the type -to the correct service id (see :ref:`autowiring-interface-alias`). +``App\Util\TransformerInterface`` type. Autowiring subsystem can not decide which +one to use. Remember, Autowiring isn't magic: it simply +looks for a service whose id matches the type-hint. So you need to choose one by +creating an alias from the type to the correct service id +(see :ref:`autowiring-interface-alias`). If you want ``Rot13Transformer`` to be the service that's used for autowiring, create that alias: From a93995df3e12bcff5e522d64dfeb4ab024b377d6 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 16 May 2018 15:12:13 +0200 Subject: [PATCH 2/2] Fixed formatting --- service_container/autowiring.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index cf582ab763f..ddd6a4618e1 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -358,11 +358,10 @@ Suppose you create a second class - ``UppercaseTransformer`` that implements } If you register this as a service, you now have *two* services that implement the -``App\Util\TransformerInterface`` type. Autowiring subsystem can not decide which -one to use. Remember, Autowiring isn't magic: it simply -looks for a service whose id matches the type-hint. So you need to choose one by -creating an alias from the type to the correct service id -(see :ref:`autowiring-interface-alias`). +``App\Util\TransformerInterface`` type. Autowiring subsystem can not decide +which one to use. Remember, autowiring isn't magic; it simply looks for a service +whose id matches the type-hint. So you need to choose one by creating an alias +from the type to the correct service id (see :ref:`autowiring-interface-alias`). If you want ``Rot13Transformer`` to be the service that's used for autowiring, create that alias: