Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / field / src / FieldStorageConfigAccessControlHandler.php
1 <?php
2
3 namespace Drupal\field;
4
5 use Drupal\Core\Access\AccessResult;
6 use Drupal\Core\Entity\EntityAccessControlHandler;
7 use Drupal\Core\Entity\EntityInterface;
8 use Drupal\Core\Session\AccountInterface;
9
10 /**
11  * Defines the access control handler for the field storage config entity type.
12  *
13  * @see \Drupal\field\Entity\FieldStorageConfig
14  */
15 class FieldStorageConfigAccessControlHandler extends EntityAccessControlHandler {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
21     /** \Drupal\field\FieldStorageConfigInterface $entity */
22     if ($operation === 'delete') {
23       if ($entity->isLocked()) {
24         return AccessResult::forbidden()->addCacheableDependency($entity);
25       }
26       else {
27         return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields')->addCacheableDependency($entity);
28       }
29     }
30     return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields');
31   }
32
33 }