Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Allow to pass a single value for the groups opt#10312

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 3 commits intosymfony:masterfromdunglas:pr_27503
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioncomponents/serializer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,7 +337,7 @@ You are now able to serialize only attributes in the groups you want::
$normalizer = new ObjectNormalizer($classMetadataFactory);
$serializer = new Serializer(array($normalizer));

$data = $serializer->normalize($obj, null, array('groups' =>array('group1')));
$data = $serializer->normalize($obj, null, array('groups' => 'group1'));
// $data = array('foo' => 'foo');

$obj2 = $serializer->denormalize(
Expand Down
9 changes: 8 additions & 1 deletionserializer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -130,9 +130,16 @@ to your class and choose which groups to use when serializing::

$json = $serializer->serialize(
$someObject,
'json', array('groups' =>array('group1'))
'json', array('groups' => 'group1')
);

.. tip::

The value of the ``groups`` key can be a single string, or an array of strings.

.. versionadded:: 4.2
The option to pass a single string to ``groups`` was introduced in Symfony 4.2.

In addition to the ``@Groups`` annotation, the Serializer component also
supports YAML or XML files. These files are automatically loaded when being
stored in one of the following locations:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp