public function GroupMembershipLoader::loadByGroup in Group 8
Same name and namespace in other branches
- 2.0.x src/GroupMembershipLoader.php \Drupal\group\GroupMembershipLoader::loadByGroup()
Loads all memberships for a group.
Parameters
\Drupal\group\Entity\GroupInterface $group: The group to load the memberships from.
string|array $roles: (optional) A group role machine name or a list of group role machine names to filter on. Valid results only need to match on one role.
Return value
\Drupal\group\GroupMembership[] The loaded GroupMemberships matching the criteria.
Overrides GroupMembershipLoaderInterface::loadByGroup
File
- src/
GroupMembershipLoader.php, line 90
Class
- GroupMembershipLoader
- Loader for wrapped GroupContent entities using the 'group_membership' plugin.
Namespace
Drupal\groupCode
public function loadByGroup(GroupInterface $group, $roles = NULL) {
$filters = [];
if (isset($roles)) {
$filters['group_roles'] = (array) $roles;
}
$group_contents = $this
->groupContentStorage()
->loadByGroup($group, 'group_membership', $filters);
return $this
->wrapGroupContentEntities($group_contents);
}