- 🇳🇿New Zealand jlscott
When working with Group v2 or Group v3, the query will need to be updated to:
$group_roles = $this->entityTypeManager->getStorage('group_role')->loadByProperties([ 'group_type' => 'my_group_type', 'scope' => 'individual', ]);
At this point I am extreme frustrated, I have spent all day on this, and still can't accomplish what should be a basic task. Below I have some code to load all the group roles available to the "client" group type. $group_role_syncronizer produces an array with 3 group role ids, but when I go into the foreach loop to load each group role, only the first one loads, and the 2nd group role returns null upon load. To try and rule out issues here, I have added my admin (whom I'm logged in as) to all roles, but it still only loads the first role.
I simply need a list of all roles available to a group type, how do I accomplish this?
$group_role_syncronizer = \Drupal::service('group_role.synchronizer');
$roleIds = $group_role_syncronizer->getGroupRoleIdsByGroupType('client');
$options = [];
foreach ($roleIds as $id) {
$role = \Drupal\group\Entity\GroupRole::load($id);
$options[$id] = $role->label();
}
Fixed
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
When working with Group v2 or Group v3, the query will need to be updated to:
$group_roles = $this->entityTypeManager->getStorage('group_role')->loadByProperties([
'group_type' => 'my_group_type',
'scope' => 'individual',
]);