function FieldStorageConfigAccessControlHandler::checkAccess
Same name and namespace in other branches
- 8.9.x core/modules/field/src/FieldStorageConfigAccessControlHandler.php \Drupal\field\FieldStorageConfigAccessControlHandler::checkAccess()
- 10 core/modules/field/src/FieldStorageConfigAccessControlHandler.php \Drupal\field\FieldStorageConfigAccessControlHandler::checkAccess()
- 11.x core/modules/field/src/FieldStorageConfigAccessControlHandler.php \Drupal\field\FieldStorageConfigAccessControlHandler::checkAccess()
Performs access checks.
This method is supposed to be overwritten by extending classes that do their own custom access checking.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check access.
string $operation: The entity operation. Usually one of 'view', 'view label', 'update' or 'delete'.
\Drupal\Core\Session\AccountInterface $account: The user for which to check access.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides EntityAccessControlHandler::checkAccess
File
-
core/
modules/ field/ src/ FieldStorageConfigAccessControlHandler.php, line 20
Class
- FieldStorageConfigAccessControlHandler
- Defines the access control handler for the field storage config entity type.
Namespace
Drupal\fieldCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** \Drupal\field\FieldStorageConfigInterface $entity */
if ($operation === 'delete') {
if ($entity->isLocked()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
else {
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields')
->addCacheableDependency($entity);
}
}
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.