You are here

public function OgChangeMultipleRolesFormBase::access in Organic groups 8

Controls access to the form.

Parameters

\Drupal\Core\Session\AccountInterface $account: The account for which to check access.

Return value

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

File

src/Form/OgChangeMultipleRolesFormBase.php, line 133

Class

OgChangeMultipleRolesFormBase
Base class for forms that act on multiple roles.

Namespace

Drupal\og\Form

Code

public function access(AccountInterface $account) {

  // Only grant access to the form if there are memberships to process, and if
  // the user has permission to manage members on all the memberships.
  $memberships = $this
    ->getMemberships();
  $access = AccessResult::allowedIf(!empty($memberships));
  while ($access
    ->isAllowed() && ($membership = array_shift($memberships))) {
    $access = $this->ogAccess
      ->userAccess($membership
      ->getGroup(), 'manage members', $account);
  }
  return $access;
}