@@ -592,19 +592,19 @@ Using it in practice::
592
592
Decorating the ObjectMapper
593
593
---------------------------
594
594
595
- The ``object_mapper `` service can be decorated to add custom logic and state
596
- management around the mapping process.
595
+ The ``object_mapper `` service can be decorated to add custom logic or manage
596
+ state around the mapping process.
597
597
598
- One can use the
599
- :class: ` Symfony \\ Component \\ ObjectMapper \\ ObjectMapperAwareInterface `. When a
600
- decorator is applied, it can pass itself to the decorated service (if it implements
601
- this interface) . This allows the underlying services, like the ``ObjectMapper ``,
602
- to use the top-level decorator's ``map() `` method for recursive mapping, ensuring
603
- that the decorator's state is consistently used .
598
+ You can use the :class: ` Symfony \\ Component \\ ObjectMapper \\ ObjectMapperAwareInterface `
599
+ to enable the decorated service to access the outermost decorator. If the
600
+ decorated service implements this interface, the decorator can pass itself to
601
+ it . This allows underlying services, like the ``ObjectMapper ``, to call the
602
+ decorator's ``map() `` method during recursive mapping, ensuring that the
603
+ decorator's state is used consistently throughout the process .
604
604
605
- Here is an example of a decorator that preserves object identity across calls.
605
+ Here's an example of a decorator that preserves object identity across calls.
606
606
It uses the ``AsDecorator `` attribute to automatically configure itself as a
607
- decorator for the ``object_mapper `` service::
607
+ decorator of the ``object_mapper `` service::
608
608
609
609
// src/ObjectMapper/StatefulObjectMapper.php
610
610
namespace App\ObjectMapper;
@@ -618,7 +618,7 @@ decorator for the ``object_mapper`` service::
618
618
{
619
619
public function __construct(private ObjectMapperInterface $decorated)
620
620
{
621
- // Pass this decorator to the decorated service if it's aware
621
+ // pass this decorator to the decorated service if it's aware
622
622
if ($this->decorated instanceof ObjectMapperAwareInterface) {
623
623
$this->decorated = $this->decorated->withObjectMapper($this);
624
624
}
@@ -630,6 +630,9 @@ decorator for the ``object_mapper`` service::
630
630
}
631
631
}
632
632
633
+ .. versionadded :: 7.4
634
+
635
+ The feature to decorate the ObjetMapper was introduced in Symfony 7.4.
633
636
634
637
.. _objectmapper-custom-mapping-logic :
635
638
0 commit comments