Skip to content

[Autowiring] - Rephrase aliasing when multiple classes with same interface #9755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions service_container/autowiring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down