bug #34490 [Serializer] Fix MetadataAwareNameConverter usage with string 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
-------
d4f749a465
[Serializer] Fix MetadataAwareNameConverter usage with string group
This commit is contained in:
commit
33731bf287
@ -123,7 +123,7 @@ final class MetadataAwareNameConverter implements AdvancedNameConverterInterface
|
||||
if (!$groups && ($context[AbstractNormalizer::GROUPS] ?? [])) {
|
||||
continue;
|
||||
}
|
||||
if ($groups && !array_intersect($groups, $context[AbstractNormalizer::GROUPS] ?? [])) {
|
||||
if ($groups && !array_intersect($groups, (array) ($context[AbstractNormalizer::GROUPS] ?? []))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,8 @@ final class MetadataAwareNameConverterTest extends TestCase
|
||||
return [
|
||||
['buz', 'buz', ['groups' => ['a']]],
|
||||
['buzForExport', 'buz', ['groups' => ['b']]],
|
||||
['buz', 'buz', ['groups' => 'a']],
|
||||
['buzForExport', 'buz', ['groups' => 'b']],
|
||||
['buz', 'buz', ['groups' => ['c']]],
|
||||
['buz', 'buz', []],
|
||||
];
|
||||
|
Reference in New Issue
Block a user