class PermissionAccessCheck

Determines access to routes based on permissions defined via hook_permission().

Hierarchy

Expanded class hierarchy of PermissionAccessCheck

1 string reference to 'PermissionAccessCheck'
user.services.yml in drupal/core/modules/user/user.services.yml
drupal/core/modules/user/user.services.yml
1 service uses PermissionAccessCheck

File

drupal/core/modules/user/lib/Drupal/user/Access/PermissionAccessCheck.php, line 17
Contains Drupal\user\Access\PermissionAccessCheck.

Namespace

Drupal\user\Access
View source
class PermissionAccessCheck implements AccessCheckInterface {

  /**
   * Implements AccessCheckInterface::applies().
   */
  public function applies(Route $route) {
    return array_key_exists('_permission', $route
      ->getRequirements());
  }

  /**
   * Implements AccessCheckInterface::access().
   */
  public function access(Route $route, Request $request) {
    $permission = $route
      ->getRequirement('_permission');

    // @todo Replace user_access() with a correctly injected and session-using
    //   alternative.
    // If user_access() fails, return NULL to give other checks a chance.
    return user_access($permission) ? static::ALLOW : static::DENY;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AccessCheckInterface::ALLOW constant Grant access.
AccessCheckInterface::DENY constant Deny access.
AccessCheckInterface::KILL constant Block access.
PermissionAccessCheck::access public function Implements AccessCheckInterface::access(). Overrides AccessCheckInterface::access
PermissionAccessCheck::applies public function Implements AccessCheckInterface::applies(). Overrides AccessCheckInterface::applies