Skip to content

[Serializer] Add docs for attributes context key #8830

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 3 commits into from
Dec 13, 2017

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Dec 4, 2017

Documentation for symfony/symfony#18834

$serializer = new Serializer(array(new ObjectNormalizer()));

$data = $serializer->normalize($user, null, array('attributes' => array('familyName', 'company' => ['name'])));
// $data = array('familyName' => 'Dunglas', 'company' => ['name' => 'Les-Tilleuls.coop']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'company' => ['name' ... -> 'company' => array('name' ...

Only attributes that are not ignored (see below) are available.
If some serialization groups are set, only attributes allowed by those groups can be used.

As for groups, attributes can be applied during both the serialization and deserialization.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this phrase means -> "As for groups, attributes can be applied during both the serialization and deserialization."

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfectly explained, concise and with a good example.

Thank you!

@weaverryan
Copy link
Member

Thanks @dunglas!

@weaverryan weaverryan merged commit d48d6d4 into symfony:3.3 Dec 13, 2017
weaverryan added a commit that referenced this pull request Dec 13, 2017
…as, javiereguiluz)

This PR was merged into the 3.3 branch.

Discussion
----------

[Serializer] Add docs for attributes context key

Documentation for symfony/symfony#18834

Commits
-------

d48d6d4 Minor reword
ea211ab Review
5d75696 [Serializer] Add docs for attributes context key
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