function NodeTypeAccessControlHandler::checkAccess

Same name in other branches
  1. 9 core/modules/node/src/NodeTypeAccessControlHandler.php \Drupal\node\NodeTypeAccessControlHandler::checkAccess()
  2. 8.9.x core/modules/node/src/NodeTypeAccessControlHandler.php \Drupal\node\NodeTypeAccessControlHandler::checkAccess()
  3. 11.x core/modules/node/src/NodeTypeAccessControlHandler.php \Drupal\node\NodeTypeAccessControlHandler::checkAccess()

Overrides EntityAccessControlHandler::checkAccess

File

core/modules/node/src/NodeTypeAccessControlHandler.php, line 20

Class

NodeTypeAccessControlHandler
Defines the access control handler for the node type entity type.

Namespace

Drupal\node

Code

protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    switch ($operation) {
        case 'view':
            return AccessResult::allowedIfHasPermission($account, 'access content');
        case 'delete':
            if ($entity->isLocked()) {
                return AccessResult::forbidden()->addCacheableDependency($entity);
            }
            else {
                return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
            }
            break;
        default:
            return parent::checkAccess($entity, $operation, $account);
    }
}

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