Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47f81eb

Browse filesBrowse files
committed
Mention resolve_target_entities support in EntityValueResolver
1 parent 0d01dbc commit 47f81eb
Copy full SHA for 47f81eb

File tree

2 files changed

+27
-0
lines changed
Filter options

2 files changed

+27
-0
lines changed

‎doctrine.rst

Copy file name to clipboardExpand all lines: doctrine.rst
+22Lines 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

Copy file name to clipboardExpand all lines: doctrine/resolve_target_entity.rst
+5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.