class PermissionAccessCheck in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/src/Access/PermissionAccessCheck.php \Drupal\user\Access\PermissionAccessCheck
Determines access to routes based on permissions defined via $module.permissions.yml files.
Hierarchy
- class \Drupal\user\Access\PermissionAccessCheck implements AccessInterface
Expanded class hierarchy of PermissionAccessCheck
1 file declares its use of PermissionAccessCheck
- PermissionAccessCheckTest.php in core/
modules/ user/ tests/ src/ Unit/ PermissionAccessCheckTest.php
1 string reference to 'PermissionAccessCheck'
- user.services.yml in core/
modules/ user/ user.services.yml - core/modules/user/user.services.yml
1 service uses PermissionAccessCheck
- access_check.permission in core/
modules/ user/ user.services.yml - Drupal\user\Access\PermissionAccessCheck
File
- core/
modules/ user/ src/ Access/ PermissionAccessCheck.php, line 14
Namespace
Drupal\user\AccessView source
class PermissionAccessCheck implements AccessInterface {
/**
* Checks access.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access(Route $route, AccountInterface $account) {
$permission = $route
->getRequirement('_permission');
if ($permission === NULL) {
return AccessResult::neutral();
}
// Allow to conjunct the permissions with OR ('+') or AND (',').
$split = explode(',', $permission);
if (count($split) > 1) {
return AccessResult::allowedIfHasPermissions($account, $split, 'AND');
}
else {
$split = explode('+', $permission);
return AccessResult::allowedIfHasPermissions($account, $split, 'OR');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PermissionAccessCheck:: |
public | function | Checks access. |