Skip to content

Commit

Permalink
bug #34490 [Serializer] Fix MetadataAwareNameConverter usage with str…
Browse files Browse the repository at this point in the history
…ing group (antograssiot)

This PR was merged into the 4.3 branch.

Discussion
----------

[Serializer] Fix MetadataAwareNameConverter usage with string group

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34455
| License       | MIT
| Doc PR        |

Allow to use the short syntax for serialization context group like `['groups' => 'user']`

Commits
-------

d4f749a [Serializer] Fix MetadataAwareNameConverter usage with string group
  • Loading branch information
nicolas-grekas committed Nov 28, 2019
2 parents 63e6f87 + d4f749a commit 33731bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function getCacheValueForAttributesMetadata(string $class, array $contex
if (!$groups && ($context[AbstractNormalizer::GROUPS] ?? [])) {
continue;
}
if ($groups && !array_intersect($groups, $context[AbstractNormalizer::GROUPS] ?? [])) {
if ($groups && !array_intersect($groups, (array) ($context[AbstractNormalizer::GROUPS] ?? []))) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public function attributeAndContextProvider()
return [
['buz', 'buz', ['groups' => ['a']]],
['buzForExport', 'buz', ['groups' => ['b']]],
['buz', 'buz', ['groups' => 'a']],
['buzForExport', 'buz', ['groups' => 'b']],
['buz', 'buz', ['groups' => ['c']]],
['buz', 'buz', []],
];
Expand Down

0 comments on commit 33731bf

Please sign in to comment.