You are here

public static function WebformAccessGroupAccess::checkAdminAccess in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_access/src/Access/WebformAccessGroupAccess.php \Drupal\webform_access\Access\WebformAccessGroupAccess::checkAdminAccess()

Check whether the current user is a administor or assign admin access.

Return value

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

1 string reference to 'WebformAccessGroupAccess::checkAdminAccess'
webform_access.routing.yml in modules/webform_access/webform_access.routing.yml
modules/webform_access/webform_access.routing.yml

File

modules/webform_access/src/Access/WebformAccessGroupAccess.php, line 19

Class

WebformAccessGroupAccess
Defines the custom access control handler for the webform access groups.

Namespace

Drupal\webform_access\Access

Code

public static function checkAdminAccess() {
  $account = \Drupal::currentUser();
  if ($account
    ->hasPermission('administer webform')) {
    $access_result = AccessResult::allowed();
  }
  elseif (static::isAdmin($account)) {
    $access_result = AccessResult::allowed();
    $access_result
      ->addCacheTags([
      'webform_access_group_list',
    ]);
  }
  else {
    $access_result = AccessResult::neutral();
  }
  return $access_result
    ->addCacheableDependency($account);
}