Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PermissionCheckerInterface.php

interface PermissionCheckerInterface

Defines a permission checker interface.

This service checks if a role has a permission. It can be swapped out or decorated to allow for more complex logic. If you do so, ensure that you provide ample automated tests so your site remains secure.

Hierarchy

  • interface \Drupal\Core\Session\PermissionCheckerInterface

Expanded class hierarchy of PermissionCheckerInterface

All classes that implement PermissionCheckerInterface

Related topics

User accounts, permissions, and roles
API for user accounts, access checking, roles, and permissions.

File

core/lib/Drupal/Core/Session/PermissionCheckerInterface.php, line 14

Namespace

Drupal\Core\Session
View source
interface PermissionCheckerInterface {
    
    /**
     * Checks whether an account has a permission.
     *
     * @param string $permission
     *   The name of the permission to check for.
     * @param \Drupal\Core\Session\AccountInterface $account
     *   The user account for which to check the permissions.
     *
     * @return bool
     *   Whether the account has the permission.
     */
    public function hasPermission(string $permission, AccountInterface $account) : bool;

}

Members

Title Sort descending Modifiers Object type Summary Overrides
PermissionCheckerInterface::hasPermission public function Checks whether an account has a permission. 1
RSS feed
Powered by Drupal