Skip to content

[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

Merged
merged 1 commit into from
Sep 21, 2016

Conversation

michaelperrin
Copy link
Contributor

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)?


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:
Copy link
Member

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

Copy link
Member

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.
Copy link
Member

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

Copy link
Member

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``).

@weaverryan
Copy link
Member

This looks good! I just added a few minor comments, but I'm going to mark this as:

Status: Reviewed

@xabbuh xabbuh merged commit 299ac85 into symfony:2.8 Sep 21, 2016
xabbuh added a commit that referenced this pull request Sep 21, 2016
…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
xabbuh added a commit that referenced this pull request Sep 21, 2016
@xabbuh
Copy link
Member

xabbuh commented Sep 21, 2016

Thank you @michaelperrin!

@xabbuh
Copy link
Member

xabbuh commented Sep 21, 2016

see #6992 for the versionadded directive

xabbuh added a commit that referenced this pull request Sep 21, 2016
* 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
  ...
xabbuh added a commit that referenced this pull request Sep 21, 2016
* 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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants