Skip to content

[JsonStreamer] Mention how to get the current object in value transformers #21275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions serializer/streaming_json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ When callables are not enough, you can use a service implementing the
The ``getStreamValueType()`` method must return the value's type as it will
appear in the JSON stream.

.. tip::

The ``$options`` argument of the ``transform()`` method includes a special
option called ``_current_object`` which gives access to the object holding
the current property (or ``null`` if there's none).

.. versionadded:: 7.4

The ``_current_object`` option was introduced in Symfony 7.4.

To use this transformer in a class, configure the ``#[ValueTransformer]`` attribute::

// src/Dto/Dog.php
Expand Down