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#27503

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
nicolas-grekas merged 1 commit intosymfony:masterfromdunglas:serializer-1-group
Jul 1, 2018

Conversation

@dunglas
Copy link
Member

@dunglasdunglas commentedJun 5, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRsymfony/symfony-docs#10312

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:

$serializer->serialize($foo,'json', ['groups' => ['myGroup']];/** @ApiResource(normalizationContext={"groups"={"myGroup"}}) */

After:

$serializer->serialize($foo,'json', ['groups' =>'myGroup'];/** @ApiResource(normalizationContext={"groups"="myGroup") */

jbdelhommeau, linaori, ScullWM, lyrixx, yceruto, Airone2000, and teohhanhui reacted with thumbs up emoji
@lyrixx
Copy link
Member

Huge 👍 because the previous&& \is_array($context[static::GROUPS] is really a time killer

@dunglas
Copy link
MemberAuthor

Travis failure not related.

@nicolas-grekasnicolas-grekas added this to thenext milestoneJun 6, 2018
Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

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

Can you add a note in the changelog file?

Copy link

@20uf20uf left a comment

Choose a reason for hiding this comment

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

Nice job !

if (isset($context[static::GROUPS]) &&\is_array($context[static::GROUPS])) {
$groups =$context[static::GROUPS];
if (isset($context[static::GROUPS])) {
$groups =(array)$context[static::GROUPS];

Choose a reason for hiding this comment

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

shouldn't this check is_scalar||is_array instead of casting objects?

fabpot reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

done

@nicolas-grekas
Copy link
Member

Thank you@dunglas.

@nicolas-grekasnicolas-grekas merged commit5b39203 intosymfony:masterJul 1, 2018
nicolas-grekas added a commit that referenced this pull requestJul 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     <!-- seehttps://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        | todoShortcut 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
@dunglasdunglas deleted the serializer-1-group branchJuly 2, 2018 09:20
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestSep 11, 2018
… opt (dunglas, javiereguiluz)This PR was merged into the master branch.Discussion----------[Serializer] Allow to pass a single value for the groups optsymfony/symfony#27503Commits-------ae558f4 Added the missing versionadded directivee4eae25 Replaced a "note" by a "tip"5e0a91e [Serializer] Allow to pass a single value for the groups opt
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@fabpotfabpotfabpot approved these changes

@lyrixxlyrixxlyrixx approved these changes

+5 more reviewers

@srozesrozesroze approved these changes

@ogizanagiogizanagiogizanagi approved these changes

@PierstovalPierstovalPierstoval approved these changes

@SimperfitSimperfitSimperfit approved these changes

@20uf20uf20uf approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

10 participants

@dunglas@lyrixx@nicolas-grekas@fabpot@sroze@ogizanagi@Pierstoval@Simperfit@20uf@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp