function PermissionChecker::hasPermission
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Session/PermissionChecker.php \Drupal\Core\Session\PermissionChecker::hasPermission()
File
-
core/
lib/ Drupal/ Core/ Session/ PermissionChecker.php, line 23
Class
- PermissionChecker
- Checks permissions for an account.
Namespace
Drupal\Core\SessionCode
public function hasPermission(string $permission, AccountInterface $account) : bool {
// User #1 has all privileges.
if ((int) $account->id() === 1) {
return TRUE;
}
return $this->entityTypeManager
->getStorage('user_role')
->isPermissionInRoles($permission, $account->getRoles());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.