public function GroupRequestController::routeAccess in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::routeAccess()
- 10.3.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::routeAccess()
- 10.0.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::routeAccess()
- 10.1.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::routeAccess()
Checks access for a specific route request to see if user can see requests.
Parameters
\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
- modules/
social_features/ social_group/ modules/ social_group_request/ src/ Controller/ GroupRequestController.php, line 201
Class
- GroupRequestController
- Returns responses for Group request routes.
Namespace
Drupal\social_group_request\ControllerCode
public function routeAccess(AccountInterface $account) {
// @todo refactor this when Group entity query access lands.
$has_administer_users = $account
->hasPermission('administer members');
if ($has_administer_users) {
return AccessResult::allowed();
}
$group = _social_group_get_current_group();
if (!$group instanceof Group) {
$group_id = \Drupal::routeMatch()
->getParameter('group');
// Views upcasting is lame.
if (!isset($group_id)) {
$group_id = \Drupal::routeMatch()
->getParameter('arg_0');
}
$group = Group::load($group_id);
}
$is_group_page = isset($group);
$is_group_manager = $group
->hasPermission('administer members', $account);
return AccessResult::allowedIf($is_group_page && $is_group_manager);
}