Skip to content

Commit 47f81eb

Browse files
committed
Mention resolve_target_entities support in EntityValueResolver
1 parent 0d01dbc commit 47f81eb

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: doctrine.rst

+22
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,28 @@ variable. Let's say you want the first or the last comment of a product dependin
780780
Comment $comment
781781
): Response {
782782
}
783+
784+
.. _doctrine-entity-value-resolver-resolve-target-entities:
785+
786+
Fetch via interfaces
787+
~~~~~~~~~~~~~~~~~~~~
788+
789+
Suppose your ``Product`` object implements an interface called ``ProductInterface``.
790+
If you want to decouple your controllers from your entity implementations, you can instead reference entities via an interface.
791+
To do this, first you need to configure the :doc:`resolve_target_entities option </doctrine/resolve_target_entity>`.
792+
793+
Your controller can then reference the Product entity by its interface instead::
794+
795+
public function show(
796+
#[MapEntity]
797+
ProductInterface $product
798+
): Response {
799+
// ...
800+
}
801+
802+
.. versionadded:: 7.3
803+
804+
Support for ``resolve_target_entites`` in the ``EntityValueResolver`` was introduced in Symfony 7.3.
783805

784806
MapEntity Options
785807
~~~~~~~~~~~~~~~~~

Diff for: doctrine/resolve_target_entity.rst

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ mappings and expect correct mapping to a concrete entity at runtime.
1414
This functionality allows you to define relationships between different entities
1515
without making them hard dependencies.
1616

17+
.. tip::
18+
19+
Starting with Symfony 7.3, this functionality also works with the ``EntityValueResolver``.
20+
See :ref:`doctrine-entity-value-resolver-resolve-target-entities` for more details.
21+
1722
Background
1823
----------
1924

0 commit comments

Comments
 (0)