function FieldStorageConfigAccessControlHandler::checkAccess

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

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\field

Code

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.