From 1f0c87c53f139c815a2e08731f8d86fb4d379123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Kami=C5=84ski?= Date: Wed, 4 May 2022 20:31:29 +0200 Subject: [PATCH] [Serializer] Document support of canners --- components/serializer.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 27d08f79ec3..706d2f492a4 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -746,8 +746,12 @@ If you are using isser methods (methods prefixed by ``is``, like ``App\Model\Person::isSportsperson()``), the Serializer component will automatically detect and use it to serialize related attributes. -The ``ObjectNormalizer`` also takes care of methods starting with ``has``, ``add`` -and ``remove``. +The ``ObjectNormalizer`` also takes care of methods starting with ``has``, ``can``, +``add`` and ``remove``. + +.. versionadded:: 6.1 + + The support of canners (methods prefixed by ``can``) was introduced in Symfony 6.1. Using Callbacks to Serialize Properties with Object Instances ------------------------------------------------------------- @@ -811,12 +815,12 @@ The Serializer component provides several built-in normalizers: :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer` This normalizer leverages the :doc:`PropertyAccess Component ` to read and write in the object. It means that it can access to properties - directly and through getters, setters, hassers, issers, adders and removers. It supports - calling the constructor during the denormalization process. + directly and through getters, setters, hassers, issers, canners, adders and removers. + It supports calling the constructor during the denormalization process. Objects are normalized to a map of property names and values (names are - generated by removing the ``get``, ``set``, ``has``, ``is``, ``add`` or ``remove`` prefix from - the method name and transforming the first letter to lowercase; e.g. + generated by removing the ``get``, ``set``, ``has``, ``is``, ``can``, ``add`` or ``remove`` + prefix from the method name and transforming the first letter to lowercase; e.g. ``getFirstName()`` -> ``firstName``). The ``ObjectNormalizer`` is the most powerful normalizer. It is configured by