function NodeTypeAccessControlHandler::checkAccess
Same name in other branches
- 9 core/modules/node/src/NodeTypeAccessControlHandler.php \Drupal\node\NodeTypeAccessControlHandler::checkAccess()
- 10 core/modules/node/src/NodeTypeAccessControlHandler.php \Drupal\node\NodeTypeAccessControlHandler::checkAccess()
- 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\nodeCode
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.