Skip to content

[Serializer] Section about configuring Circular Reference Handler #12431

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 5 commits into
base: 3.4
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ name_converter

The name converter to use.
The :class:`Symfony\\Component\\Serializer\\NameConverter\\CamelCaseToSnakeCaseNameConverter`
name converter can enabled by using the ``serializer.name_converter.camel_case_to_snake_case``
name converter can be enabled by using the ``serializer.name_converter.camel_case_to_snake_case``
value.

.. seealso::
Expand Down
16 changes: 16 additions & 0 deletions serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ value:
],
]);

Enabling Circular Reference Handler
-----------------------------------

The use of the :ref:`circular reference handler <component-serializer-handling-circular-references>` service can be defined
in the configuration using the :ref:`circular_reference_handler <reference-serializer-circular_reference_handler>` option.

A circular reference handler service has to implement the magic ``__invoke($object)`` method, like in example::

class MyCircularReferenceHandler
{
public function __invoke($object)
{
return $object->getName();
}
}

Going Further with the Serializer
---------------------------------

Expand Down