og
og copied to clipboard
331 set membership type for group type
PR for #331.
Thanks! Can you provide gif/ screenshot(s) as-well - so it's easier to get the context.
This shows the extra form element on the bundle form:
It uses states so it's only shown when the 'Group' checkbox is selected.
Just to be clear, I've not implemented the 2nd thing I suggested on #331, which was to add a setting to the GroupSubscribeFormatter. I'm not sure there's a use case for it now I think about it, as since the group settings are per-bundle, there is a 1-1 correspondence between the group bundle settings and the formatter's settings. Therefore having a setting in the formatter doesn't provide any finer-grained control. So overall, it's best to have this setting somewhere where the API uses it, rather than in the UI.
Fixed the unit test errors that the CI was reporting.
Locally I am getting 1 fail with:
- Drupal\Tests\og\Kernel\Console\DrupalConsoleAddFieldTest::testNewGroup Error: Class 'Drupal\Console\Core\Style\DrupalStyle' not found
but I expect that's because my local copy of Drupal Console is out of date.
Fixed the things the codesniffer was complaining about.
This works quite well on our build.
A couple of remarks:
- it would be great to limit membership types per group type.
- Had to have a "glue" patch for this + #231 + #181 - https://gist.github.com/zerolab/da4899abf6683180e1f07fc859b06707
it would be great to limit membership types per group type.
Not sure what you mean.
Do you mean that when you create a membership type, eg Membership Foo, you get to say in its form that it's only available for Group bundles X and Y?
That would presumably have to be enforced at the API level, since you can use the API to create a membership in any type, not just the one set for the group bundle.
Do you mean that when you create a membership type, eg Membership Foo, you get to say in its form that it's only available for Group bundles X and Y?
Yes. If I have Group Type A and Group Type B and I need a special Membership Type for just B, I don't want to add a new member to a group in A and see the special membership type that is meant just for B.
It's not my call, but I'd suggest that's left for a follow-up, as it's a fair bit more work.
This would need:
- a new property on the Group Membership type entity for the group bundles that it allows
- that possibly means adding a config dependency to the GM type, as it is referencing a bundle entity
- limiting the options shown on the group type form to the eligible GM types, and probably adding an API method to get those
- enforcing this setting in the API methods that create a group membership, so you can't pass in a GM type ID that's not allowed
Drupal 7 backport or module?