function PermissionChecker::hasPermission

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Session/PermissionChecker.php \Drupal\Core\Session\PermissionChecker::hasPermission()

Checks whether an account has a permission.

Parameters

string $permission: The name of the permission to check for.

\Drupal\Core\Session\AccountInterface $account: The user account for which to check the permissions.

Return value

bool Whether the account has the permission.

Overrides PermissionCheckerInterface::hasPermission

File

core/lib/Drupal/Core/Session/PermissionChecker.php, line 22

Class

PermissionChecker
Checks permissions for an account.

Namespace

Drupal\Core\Session

Code

public function hasPermission(string $permission, AccountInterface $account) : bool {
  $item = $this->processor
    ->processAccessPolicies($account)
    ->getItem();
  return $item && $item->hasPermission($permission);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.