Skip to content

Commit 421aa41

Browse files
committed
ref #4272 Documentation for the new PropertyNormalizer introduced in symfony/symfony#9708
1 parent 217bf5f commit 421aa41

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

components/serializer.rst

+24
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,30 @@ When serializing, you can set a callback to format a specific object property::
238238
$serializer->serialize($person, 'json');
239239
// Output: {"name":"cordoval", "age": 34, "createdAt": "2014-03-22T09:43:12-0500"}
240240

241+
Normalizers
242+
-----------
243+
244+
There are several types of normalizers available::
245+
246+
* The :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`
247+
248+
This normalizer reads the content of the class by calling the "getters" (public
249+
methods starting with "get"). It will denormalize data by calling the constructor
250+
and the "setters" (public methods starting with "set").
251+
252+
Objects are serialized to a map of property names (method name stripped of the "get"
253+
prefix and converted to lower case) to property values.
254+
255+
* The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`
256+
257+
.. versionadded:: 2.6
258+
The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`
259+
class was introduced in Symfony 2.6.
260+
261+
This normalizer directly reads and writes public properties as well as
262+
**private and protected** properties. Objects are serialized to a map of
263+
property names to property values.
264+
241265
Handling Circular References
242266
----------------------------
243267

0 commit comments

Comments
 (0)