File tree 2 files changed +27
-0
lines changed
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
780
780
Comment $comment
781
781
): Response {
782
782
}
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.
783
805
784
806
MapEntity Options
785
807
~~~~~~~~~~~~~~~~~
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.
14
14
This functionality allows you to define relationships between different entities
15
15
without making them hard dependencies.
16
16
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
+
17
22
Background
18
23
----------
19
24
You can’t perform that action at this time.
0 commit comments