public function OpignoModuleController::accessEntityBrowserGroups in Opigno module 8
Same name and namespace in other branches
- 3.x src/Controller/OpignoModuleController.php \Drupal\opigno_module\Controller\OpignoModuleController::accessEntityBrowserGroups()
File
- src/
Controller/ OpignoModuleController.php, line 1381
Class
- OpignoModuleController
- Class OpignoModuleController.
Namespace
Drupal\opigno_module\ControllerCode
public function accessEntityBrowserGroups() {
$user = \Drupal::currentUser();
// Load all user's groups and check is he has a group content manager role
$is_group_content_manager = FALSE;
foreach (\Drupal::service('group.membership_loader')
->loadByUser($user) as $group) {
$member_roles = $group
->getGroup()
->getMember($user)
->getRoles();
if (array_key_exists('learning_path-content_manager', $member_roles)) {
$is_group_content_manager = TRUE;
}
}
if ($is_group_content_manager || array_key_exists('administrator', $user
->getRoles()) || $user
->hasPermission('access media_entity_browser_groups entity browser pages')) {
return AccessResult::allowed();
}
return AccessResult::neutral();
}