public function MembershipManager::getGroupMembershipsByRoleNames in Organic groups 8
Returns the memberships of the given group filtered by role name.
Parameters
\Drupal\Core\Entity\EntityInterface $group: The group entity for which to return the memberships.
array $role_names: An array of role names to filter by. In order to retrieve a list of all memberships, pass `[OgRoleInterface::AUTHENTICATED]`.
array $states: (optional) Array with the states to return. Defaults to only returning active memberships. In order to retrieve all memberships regardless of state, pass `OgMembershipInterface::ALL_STATES`.
Return value
\Drupal\Core\Entity\EntityInterface[] The membership entities.
Overrides MembershipManagerInterface::getGroupMembershipsByRoleNames
File
- src/
MembershipManager.php, line 239
Class
- MembershipManager
- Service for managing memberships and group content.
Namespace
Drupal\ogCode
public function getGroupMembershipsByRoleNames(EntityInterface $group, array $role_names, array $states = [
OgMembershipInterface::STATE_ACTIVE,
]) {
$ids = $this
->getGroupMembershipIdsByRoleNames($group, $role_names, $states);
return $this
->loadMemberships($ids);
}