Provide helper methods to check the membership state
Closed this issue · 5 comments
pfrenssen commented
We could provide some helper methods in OgMembership
to easily check the membership state. Currently to see for example if a user is blocked we need to do:
if ($membership->getState() !== OgMembershipInterface::STATE_BLOCKED) {
}
It would be much nicer to be able to do:
if ($membership->isBlocked()) {
}
Scope
- Provide the following helper methods, and their accompanying tests:
OgMembership::isBlocked()
OgMembership::isActive()
OgMembership::isPending()
- Replace existing checks for the various states with the new methods.
pfrenssen commented
@amitaibu do you think this is a good idea? I'm trying to come up with some novice issues in case people want to help during the code sprint in Drupalaton next week.
Also, do you think the naming scheme is ok? It could also be OgMembership::isBlocked()
etc.
amitaibu commented
Yes, it a nice idea. I would go with the shorter isBlocked
pfrenssen commented
Ok, I'll update the issue summary.
dakala commented
@pfrenssen, @amitaibu PR for your review please.