Skip to content

Commit e130ceb

Browse files
committed
Tweaks
1 parent 084c4e6 commit e130ceb

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

object_mapper.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,19 @@ Using it in practice::
592592
Decorating the ObjectMapper
593593
---------------------------
594594

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.
597597

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.
604604

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.
606606
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::
608608

609609
// src/ObjectMapper/StatefulObjectMapper.php
610610
namespace App\ObjectMapper;
@@ -618,7 +618,7 @@ decorator for the ``object_mapper`` service::
618618
{
619619
public function __construct(private ObjectMapperInterface $decorated)
620620
{
621-
// Pass this decorator to the decorated service if it's aware
621+
// pass this decorator to the decorated service if it's aware
622622
if ($this->decorated instanceof ObjectMapperAwareInterface) {
623623
$this->decorated = $this->decorated->withObjectMapper($this);
624624
}
@@ -630,6 +630,9 @@ decorator for the ``object_mapper`` service::
630630
}
631631
}
632632

633+
.. versionadded:: 7.4
634+
635+
The feature to decorate the ObjetMapper was introduced in Symfony 7.4.
633636

634637
.. _objectmapper-custom-mapping-logic:
635638

0 commit comments

Comments
 (0)