I'm looking into building a custom Context Provider, specifically to provide "groups of the current user". I'm building this for another plugin, a Condition plugin, whose purpose is to filter things (e.g. Blocks) based on the current user's group roles.
I'm aware that the following issues and patches exist, which does get me somewhere:
- Group context provider - https://www.drupal.org/project/group/issues/2815971
- Group condition - https://www.drupal.org/project/group/issues/3137221
However, both patches only ever deal with a single group, i.e. the context provider only picks out essentially the first group a user belongs to, and the condition plugin is provided one group for evaluation. What I'd like to do is have the the context provider provide multiple groups (all the groups the user belongs to) and have the condition plugin accept multiple groups.
But how do I provide and consume an array of values as context value?
Most examples for context provider and plugins consuming context values only operate on single values. I've not seen examples on how to provide an array (of groups in this case).