File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff 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
784806MapEntity Options
785807~~~~~~~~~~~~~~~~~
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ mappings and expect correct mapping to a concrete entity at runtime.
1414This functionality allows you to define relationships between different entities
1515without 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+
1722Background
1823----------
1924
You can’t perform that action at this time.
0 commit comments