-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Allow to specify a single value in @Groups #20509
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Travis error not related. |
GuilhemN
reviewed
Nov 13, 2016
|
||
foreach ($data['value'] as $group) { | ||
$value = (array) $data['value']; | ||
foreach ($value as $group) { | ||
if (!is_string($group)) { | ||
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this message be adapted accordingly?
👍 Status: Reviewed |
👍 |
Thank you @dunglas. |
fabpot
added a commit
that referenced
this pull request
Dec 2, 2016
…(dunglas) This PR was squashed before being merged into the 3.3-dev branch (closes #20509). Discussion ---------- [Serializer] Allow to specify a single value in @groups | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19374 (comment) | License | MIT | Doc PR | todo Tiny DX improvement: Before: ```php use Symfony\Component\Serializer\Annotation\Groups; class Product { /** * @groups({"admins"}) */ public $itemsSold; } ``` Now allowed: ```php use Symfony\Component\Serializer\Annotation\Groups; class Product { /** * @groups("admins") */ public $itemsSold; } ``` Commits ------- 926aa48 [Serializer] Allow to specify a single value in @groups
Merged
nicolas-grekas
added a commit
that referenced
this pull request
Jul 1, 2018
…ps opt (dunglas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Serializer] Allow to pass a single value for the groups opt | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | todo Shortcut syntax similar to #20509 but for the context: allows to pass a string instead of an array of string in the serialization context when only one group if used. Before: ```php $serializer->serialize($foo, 'json', ['groups' => ['myGroup']]; /** @ApiResource(normalizationContext={"groups"={"myGroup"}}) */ ``` After: ```php $serializer->serialize($foo, 'json', ['groups' => 'myGroup']; /** @ApiResource(normalizationContext={"groups"="myGroup") */ ``` Commits ------- 5b39203 [Serializer] Allow to pass a single value for the groups opt
javiereguiluz
added a commit
to symfony/symfony-docs
that referenced
this pull request
Sep 10, 2018
…(dunglas) This PR was merged into the 3.4 branch. Discussion ---------- [Serializer] Allow to specify a single value in @groups symfony/symfony#20509 Commits ------- 99df65f [Serializer] Allow to specify a single value in @groups
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
DX
DX = Developer eXperience (anything that improves the experience of using Symfony)
Feature
Serializer
Status: Reviewed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tiny DX improvement:
Before:
Now allowed: