-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
New normalizers #6314
New normalizers #6314
Conversation
mcfedr
commented
Mar 1, 2016
Q | A |
---|---|
Doc fix? | no |
New docs? | yes symfony/symfony#17603 symfony/symfony#17411 symfony/symfony#16164 |
Applies to | 3.1 |
Fixed tickets |
@@ -511,6 +511,26 @@ There are several types of normalizers available: | |||
|
|||
Objects are normalized to a map of property names to property values. | |||
|
|||
::class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer` | |||
This normalizer works with classes that implement `\JsonSerializable`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use double backticks here and below to enclose class names, method names, etc.
This means that nested ``JsonSerializable`` classes will also be normalized. | ||
|
||
This normalizer is particularly helpful when you want to gradually migrate | ||
from an existing codebase using simple ``json_encode`` to the full Symfony |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could add a link to the PHP doc for the json_encode
function IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove the full
@@ -511,6 +511,26 @@ There are several types of normalizers available: | |||
|
|||
Objects are normalized to a map of property names to property values. | |||
|
|||
::class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The colon @theofidry is confused of comes from the double colon here (the directive is :class:
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha indeed, misread I though it was the same for the others
It may not be the best place to ask that but can't those new serializers be back-ported? Sounds extreme to apply it only to |
Should I be adding these .. versionadded:: ? |
@theofidry I would love to backport these to 2.8 but my understanding is that new features are only added to new version, I am trying to get my project up to date with 3.0 so I can use these |
New features are, indeed, only allowed in However, you can use an old version of Symfony (like 2.8) with only the Serializer Component in 3.1. |
:class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer` | ||
This normalizer converts :phpclass:`DateTimeInterface` objects (e.g. | ||
:phpclass:`DateTime` and :phpclass:`DateTimeImmutable`) into strings. | ||
By default it uses the RFC3339 format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a link to the RFC3339 specification here?
@mcfedr yes, can you please add the |
Linked direct to the example section as its probably most helpful
As far as I can see, no. 👍 |
👍 |
👍 If you think it's interesting I'll split the serializer doc in several files and add details on how to configure the |
Thank you @mcfedr. |
@dunglas Sounds like a good idea to me. |
A must do, it's an awesome feature. |