Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     if ($this->masquerade->isMasquerading()) {
         return AccessResult::forbidden()->addCacheContexts(['is_masquerading']);
     }
     // Display block for all users that has any of masquerade permissions.
     return AccessResult::allowedIfHasPermissions($account, $this->masquerade->getPermissions(), 'OR');
 }
Exemplo n.º 2
0
 /**
  * Check to see if user has any permissions to masquerade.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   Run access checks for this account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(AccountInterface $account)
 {
     // Uid 1 may masquerade as anyone.
     if ($account->id() == 1) {
         return AccessResult::allowed()->cachePerUser();
     }
     $permissions = $this->masquerade->getPermissions();
     return AccessResult::allowedIfHasPermissions($account, $permissions, 'OR');
 }