public function SocialGroupHelperService::getAllGroupsForUser in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 8.4 modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 8.6 modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 8.7 modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 8.8 modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 10.3.x modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 10.0.x modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 10.1.x modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
- 10.2.x modules/social_features/social_group/src/SocialGroupHelperService.php \Drupal\social_group\SocialGroupHelperService::getAllGroupsForUser()
Get all group memberships for a certain user.
Parameters
int $uid: The UID for which we fetch the groups he is member of.
Return value
array List of group IDs the user is member of.
File
- modules/
social_features/ social_group/ src/ SocialGroupHelperService.php, line 153
Class
- SocialGroupHelperService
- Class SocialGroupHelperService.
Namespace
Drupal\social_groupCode
public function getAllGroupsForUser($uid) {
$groups =& drupal_static(__FUNCTION__);
// Get the memberships for the user if they aren't known yet.
if (!isset($groups[$uid])) {
$group_content_types = GroupContentType::loadByEntityTypeId('user');
$group_content_types = array_keys($group_content_types);
$query = $this->database
->select('group_content_field_data', 'gcfd');
$query
->addField('gcfd', 'gid');
$query
->condition('gcfd.entity_id', $uid);
$query
->condition('gcfd.type', $group_content_types, 'IN');
$query
->execute()
->fetchAll();
$group_ids = $query
->execute()
->fetchAllAssoc('gid');
$groups[$uid] = array_keys($group_ids);
}
return $groups[$uid];
}