-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Serializer] Add information about name converter parameter #6926
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
[Serializer] Add information about name converter parameter #6926
Conversation
|
||
The use of a :ref:`name converter <component-serializer-converting-property-names-when-serializing-and-deserializing>` service can be defined in the configuration using the `name_converter` serializer parameter. | ||
|
||
The built-in :ref:`CamelCase to snake_case name converter <using-camelized-method-names-for-underscored-attributes>` can be enabled by using the `serializer.name_converter.camel_case_to_snake_case` value: |
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.
This lines a bit too long - we need to shorten them after about 72 characters
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 serializer.name...
needs two ticks, instead of just one
Enabling a name converter | ||
------------------------- | ||
|
||
The use of a :ref:`name converter <component-serializer-converting-property-names-when-serializing-and-deserializing>` service can be defined in the configuration using the `name_converter` serializer parameter. |
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.
two ticks around name_converter
as well
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.
I think should start with some explanation as to what the current behavior is. Something like:
By default, each key in the final serialized data will match the each property
name exactly (e.g. ``firstName``). But by using a :ref:`name converter <component-serializer-converting-property-names-when-serializing-and-deserializing>`,
you can transform the property names (e.g. ``firstName`` to ``first_name``).
This looks good! I just added a few minor comments, but I'm going to mark this as: Status: Reviewed |
…eter (michaelperrin) This PR was merged into the 2.8 branch. Discussion ---------- [Serializer] Add information about name converter parameter The `name_converter` option for the Serializer component configuration is only documented in the [configuration reference](http://symfony.com/doc/current/reference/configuration/framework.html#name-converter). It is not visible when reading the Serializer [How to use](http://symfony.com/doc/current/serializer.html) chapter, which makes difficult to find this option (hence an issue like this: https://github.com/symfony/symfony-standard/issues/902). Should I mention that the option was added in Symfony 2.8 (something that is not mentioned in the Configuration reference)? Commits ------- 299ac85 [Serializer] Add information about name converter parameter
Thank you @michaelperrin! |
see #6992 for the |
* 2.8: (32 commits) [#6989] some minor tweaks Added paths options in Framework::translator configuration [#6934] add remember me response listener Update events.rst [#6897] some tweaks after review Update voters.rst [#6920] some tweaks after review Note about bundle priority for PrependExtensionInterface [#6926] some tweaks after review [#6905] rewrite code example to cover the setter Change example of ignoring dependencies for yaml [FormComponent]Fix wrong mention in side note Article about logout. Clarify by_reference use Use Terminal lexer for console examples Update entity_provider.rst fixing $formatLevelMap array values Fix subject/verb agreement Fixed directory name type fix link role syntax ...
* 3.1: (50 commits) Update heroku.rst [#6989] some minor tweaks Added paths options in Framework::translator configuration [#6934] add remember me response listener Update events.rst [#6897] some tweaks after review Update voters.rst [#6920] some tweaks after review Note about bundle priority for PrependExtensionInterface [#6926] some tweaks after review [#6905] rewrite code example to cover the setter Change example of ignoring dependencies for yaml [FormComponent]Fix wrong mention in side note Article about logout. Clarify by_reference use Use Terminal lexer for console examples Update entity_provider.rst fixing $formatLevelMap array values Use the standard cache and logs dir for the micro kernel example Fix subject/verb agreement ...
The
name_converter
option for the Serializer component configuration is only documented in the configuration reference.It is not visible when reading the Serializer How to use chapter, which makes difficult to find this option (hence an issue like this: https://github.com/symfony/symfony-standard/issues/902).
Should I mention that the option was added in Symfony 2.8 (something that is not mentioned in the Configuration reference)?