You are here

public function SocialUserController::accessUsersPages in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user/src/Controller/SocialUserController.php \Drupal\social_user\Controller\SocialUserController::accessUsersPages()
  2. 8.8 modules/social_features/social_user/src/Controller/SocialUserController.php \Drupal\social_user\Controller\SocialUserController::accessUsersPages()
  3. 10.3.x modules/social_features/social_user/src/Controller/SocialUserController.php \Drupal\social_user\Controller\SocialUserController::accessUsersPages()
  4. 10.0.x modules/social_features/social_user/src/Controller/SocialUserController.php \Drupal\social_user\Controller\SocialUserController::accessUsersPages()
  5. 10.2.x modules/social_features/social_user/src/Controller/SocialUserController.php \Drupal\social_user\Controller\SocialUserController::accessUsersPages()

Checks access for user page.

Parameters

\Drupal\Core\Session\AccountInterface $account: The current user.

\Drupal\Core\Routing\RouteMatch $routeMatch: The matched route.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 string reference to 'SocialUserController::accessUsersPages'
social_user.routing.yml in modules/social_features/social_user/social_user.routing.yml
modules/social_features/social_user/social_user.routing.yml

File

modules/social_features/social_user/src/Controller/SocialUserController.php, line 95

Class

SocialUserController
Class SocialUserController.

Namespace

Drupal\social_user\Controller

Code

public function accessUsersPages(AccountInterface $account, RouteMatch $routeMatch) {

  /** @var \Drupal\user\UserInterface $user */
  $user = $routeMatch
    ->getParameter('user');
  if (isset($user)) {
    if (!$user instanceof UserInterface) {
      $user = $this->entityTypeManager
        ->getStorage('user')
        ->load($user);
    }
  }
  else {
    return AccessResult::neutral();
  }
  if ($user
    ->isBlocked()) {
    if ($account
      ->hasPermission('view blocked user')) {
      return AccessResult::allowed();
    }
    return AccessResult::forbidden();
  }
  return AccessResult::allowed();
}