File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ Object Mapper
33
44Symfony provides a mapper component to transform a given object into another one,
55simplifying 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.
78
89.. versionadded :: 7.2
910
@@ -386,7 +387,8 @@ executed *after* the target object is initially created (if the target is a
386387class name we use ``newInstanceWithoutConstructor ``) but *before * properties
387388are mapped. Its responsibility is often to return a correctly initialized
388389instance, 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.
390392
391393::
392394
@@ -479,6 +481,9 @@ specifying where its properties should come from in the *source* class. This is
479481done using the ``source `` parameter within the ``#[Map] `` attribute on the target's
480482properties.
481483
484+ Note that if both the ``source `` and the ``target `` classes define the ``#[Map] ``
485+ attribute, the ``source `` takes precedence.
486+
482487::
483488
484489 // src/Api/Payload.php - Represents data from an external API
You can’t perform that action at this time.
0 commit comments