Skip to content
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

Ability to getGroups on Context #554

Closed
phillipsnick opened this issue Feb 24, 2016 · 1 comment
Closed

Ability to getGroups on Context #554

phillipsnick opened this issue Feb 24, 2016 · 1 comment

Comments

@phillipsnick
Copy link

We can set groups on the context as defined here: https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/Context.php#L168

But theres no simple method for fetching them.

This usually results in me having to do the following code in every listener...

$attributes = $event->getContext()->attributes;

if (!$attributes->containsKey('groups')) {
    return [];
}

$groups = $attributes->get('groups')->get();

Is there a better way?

@goetas
Copy link
Collaborator

goetas commented Apr 24, 2017

Groups inside the context are there only for the group exclusion strategy proposes.

If you need to access them, you can set them explicitly in the "serialization" attributes and use them as you prefer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants