From 421aa41611175fb43cf3fbd473dbce8287ee5c17 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 9 Oct 2014 20:51:12 +1300 Subject: [PATCH 1/5] ref #4272 Documentation for the new PropertyNormalizer introduced in symfony/symfony#9708 --- components/serializer.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/serializer.rst b/components/serializer.rst index 0d26457d0aa..e88c065d964 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -238,6 +238,30 @@ When serializing, you can set a callback to format a specific object property:: $serializer->serialize($person, 'json'); // Output: {"name":"cordoval", "age": 34, "createdAt": "2014-03-22T09:43:12-0500"} +Normalizers +----------- + +There are several types of normalizers available:: + +* The :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` + +This normalizer reads the content of the class by calling the "getters" (public +methods starting with "get"). It will denormalize data by calling the constructor +and the "setters" (public methods starting with "set"). + +Objects are serialized to a map of property names (method name stripped of the "get" +prefix and converted to lower case) to property values. + +* The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` + +.. versionadded:: 2.6 + The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` + class was introduced in Symfony 2.6. + +This normalizer directly reads and writes public properties as well as +**private and protected** properties. Objects are serialized to a map of +property names to property values. + Handling Circular References ---------------------------- From 4815c4afa09fa5214e1dec462eb9e811c8f6f779 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 19 Oct 2014 10:35:30 +1300 Subject: [PATCH 2/5] Introduction about normalizers --- components/serializer.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/serializer.rst b/components/serializer.rst index e88c065d964..55de8434c7f 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -50,6 +50,8 @@ which Encoders and Normalizer are going to be available:: $serializer = new Serializer($normalizers, $encoders); +There are several normalizers available, e.g. the :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` or the :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`. To read more about them, refer to the "Normalizers" section in this page. All the examples shown below use the GetSetMethodNormalizer. + Serializing an Object --------------------- From 6868a1999a5849acf9e4a5e7174936f6d6288ed7 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 9 Oct 2014 22:53:53 +1300 Subject: [PATCH 3/5] Updated the rendering of the list --- components/serializer.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 55de8434c7f..a7684342adc 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -247,22 +247,22 @@ There are several types of normalizers available:: * The :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` -This normalizer reads the content of the class by calling the "getters" (public -methods starting with "get"). It will denormalize data by calling the constructor -and the "setters" (public methods starting with "set"). + This normalizer reads the content of the class by calling the "getters" (public + methods starting with "get"). It will denormalize data by calling the constructor + and the "setters" (public methods starting with "set"). -Objects are serialized to a map of property names (method name stripped of the "get" -prefix and converted to lower case) to property values. + Objects are serialized to a map of property names (method name stripped of the "get" + prefix and converted to lower case) to property values. * The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` -.. versionadded:: 2.6 - The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` - class was introduced in Symfony 2.6. + .. versionadded:: 2.6 + The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` + class was introduced in Symfony 2.6. -This normalizer directly reads and writes public properties as well as -**private and protected** properties. Objects are serialized to a map of -property names to property values. + This normalizer directly reads and writes public properties as well as + **private and protected** properties. Objects are serialized to a map of + property names to property values. Handling Circular References ---------------------------- From 629c8acb43a35a2bdb5bc9a9fb6ad0c4a61fad59 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 2 Nov 2014 00:03:09 +1300 Subject: [PATCH 4/5] =?UTF-8?q?Added=20line=20returns=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/serializer.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/serializer.rst b/components/serializer.rst index a7684342adc..03ac95ed5ef 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -50,7 +50,11 @@ which Encoders and Normalizer are going to be available:: $serializer = new Serializer($normalizers, $encoders); -There are several normalizers available, e.g. the :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` or the :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`. To read more about them, refer to the "Normalizers" section in this page. All the examples shown below use the GetSetMethodNormalizer. +There are several normalizers available, e.g. the +:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` or the +:class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`. +To read more about them, refer to the "Normalizers" section in this page. +All the examples shown below use the GetSetMethodNormalizer. Serializing an Object --------------------- From 3b96301ca026ccb94814a20fb3b178278a7704f5 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Thu, 19 Feb 2015 23:54:59 +0100 Subject: [PATCH 5/5] Applied comments --- components/serializer.rst | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 03ac95ed5ef..3acac73a647 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -51,10 +51,10 @@ which Encoders and Normalizer are going to be available:: $serializer = new Serializer($normalizers, $encoders); There are several normalizers available, e.g. the -:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` or the -:class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`. -To read more about them, refer to the "Normalizers" section in this page. -All the examples shown below use the GetSetMethodNormalizer. +:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` or +the :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`. +To read more about them, refer to the `Normalizers`_ section of this page. All +the examples shown below use the ``GetSetMethodNormalizer``. Serializing an Object --------------------- @@ -247,26 +247,24 @@ When serializing, you can set a callback to format a specific object property:: Normalizers ----------- -There are several types of normalizers available:: +There are several types of normalizers available: -* The :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` +:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` + This normalizer reads the content of the class by calling the "getters" + (public methods starting with "get"). It will denormalize data by calling + the constructor and the "setters" (public methods starting with "set"). - This normalizer reads the content of the class by calling the "getters" (public - methods starting with "get"). It will denormalize data by calling the constructor - and the "setters" (public methods starting with "set"). + Objects are serialized to a map of property names (method name stripped of + the "get" prefix and converted to lower case) to property values. - Objects are serialized to a map of property names (method name stripped of the "get" - prefix and converted to lower case) to property values. +:class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` + This normalizer directly reads and writes public properties as well as + **private and protected** properties. Objects are normalized to a map of + property names to property values. -* The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` - - .. versionadded:: 2.6 - The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` - class was introduced in Symfony 2.6. - - This normalizer directly reads and writes public properties as well as - **private and protected** properties. Objects are serialized to a map of - property names to property values. +.. versionadded:: 2.6 The + :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` + class was introduced in Symfony 2.6. Handling Circular References ----------------------------