File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ Object Mapper
3
3
4
4
Symfony provides a mapper component to transform a given object into another one,
5
5
simplifying tasks like converting DTOs (Data Transfer Objects) to entities or
6
- vice-versa.
6
+ vice-versa. It may also be useful when decoupling API input/output from internal
7
+ models helping with legacy code or hexagonal architectures implementations.
7
8
8
9
.. versionadded :: 7.2
9
10
@@ -386,7 +387,8 @@ executed *after* the target object is initially created (if the target is a
386
387
class name we use ``newInstanceWithoutConstructor ``) but *before * properties
387
388
are mapped. Its responsibility is often to return a correctly initialized
388
389
instance, potentially replacing the one created by the mapper.
389
- The returned value *must * be an object of the target type.
390
+ The returned value *must * be an object of the target type or else an
391
+ exception will be thrown.
390
392
391
393
::
392
394
@@ -479,6 +481,9 @@ specifying where its properties should come from in the *source* class. This is
479
481
done using the ``source `` parameter within the ``#[Map] `` attribute on the target's
480
482
properties.
481
483
484
+ Note that if both the ``source `` and the ``target `` classes define the ``#[Map] ``
485
+ attribute, the ``source `` takes precedence.
486
+
482
487
::
483
488
484
489
// src/Api/Payload.php - Represents data from an external API
You can’t perform that action at this time.
0 commit comments