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

doctrine.rst

Lines changed: 22 additions & 0 deletions
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
~~~~~~~~~~~~~~~~~

doctrine/resolve_target_entity.rst

Lines changed: 5 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy