amitaibu/og

Provide helper methods to check the membership state

Closed this issue · 5 comments

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

  1. Provide the following helper methods, and their accompanying tests:
    • OgMembership::isBlocked()
    • OgMembership::isActive()
    • OgMembership::isPending()
  2. Replace existing checks for the various states with the new methods.

@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.

Yes, it a nice idea. I would go with the shorter isBlocked

Ok, I'll update the issue summary.

@pfrenssen, @amitaibu PR for your review please.

Thanks @dakala! I've also added you to this repo, so you can push your code here, and we can collaborate more easily.