amitaibu / og

A fork to work on OG8
https://github.com/Gizra/og
29 stars 16 forks source link

Provide helper methods to check the membership state #294

Closed pfrenssen closed 8 years ago

pfrenssen commented 8 years ago

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.
pfrenssen commented 8 years ago

@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 8 years ago

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

pfrenssen commented 8 years ago

Ok, I'll update the issue summary.

dakala commented 8 years ago

@pfrenssen, @amitaibu PR for your review please.

amitaibu commented 8 years ago

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