public function SocialGroupController::myGroupAccess in Open Social 8.9
Same name and namespace in other branches
- 8.3 modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 8.4 modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 8.5 modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 8.6 modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 8.7 modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 8.8 modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 10.3.x modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 10.0.x modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 10.1.x modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
- 10.2.x modules/social_features/social_group/src/Controller/SocialGroupController.php \Drupal\social_group\Controller\SocialGroupController::myGroupAccess()
Function that checks access on the my groups pages.
Parameters
\Drupal\Core\Session\AccountInterface $account: The account we need to check access for.
Return value
\Drupal\Core\Access\AccessResult If access is allowed.
File
- modules/
social_features/ social_group/ src/ Controller/ SocialGroupController.php, line 168
Class
- SocialGroupController
- Returns responses for Social Group routes.
Namespace
Drupal\social_group\ControllerCode
public function myGroupAccess(AccountInterface $account) {
// Fetch user from url.
$user = $this->requestStack
->getCurrentRequest()
->get('user');
// If we don't have a user in the request, assume it's my own profile.
if (is_null($user)) {
// Usecase is the user menu, which is generated on all LU pages.
$user = User::load($account
->id());
}
// If not a user then just return neutral.
if (!$user instanceof User) {
$user = User::load($user);
if (!$user instanceof User) {
return AccessResult::neutral();
}
}
if ($user
->isBlocked()) {
return AccessResult::allowedIfHasPermission($account, 'view blocked user');
}
// Own profile?
if ($user
->id() === $account
->id()) {
return AccessResult::allowedIfHasPermission($account, 'view groups on my profile');
}
return AccessResult::allowedIfHasPermission($account, 'view groups on other profiles');
}