6ee0e05cb655a6b32772283b2dd5d92c3a33f179
[yaffs-website] / web / core / modules / field / src / FieldConfigAccessControlHandler.php
1 <?php
2
3 namespace Drupal\field;
4
5 use Drupal\Core\Entity\EntityAccessControlHandler;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Session\AccountInterface;
8
9 /**
10  * Defines the access control handler for the field config entity type.
11  *
12  * @see \Drupal\field\Entity\FieldConfig
13  */
14 class FieldConfigAccessControlHandler extends EntityAccessControlHandler {
15
16   /**
17    * {@inheritdoc}
18    */
19   protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
20     // Delegate access control to the underlying field storage config entity:
21     // the field config entity merely handles configuration for a particular
22     // bundle of an entity type, the bulk of the logic and configuration is with
23     // the field storage config entity. Therefore, if an operation is allowed on
24     // a certain field storage config entity, it should also be allowed for all
25     // associated field config entities.
26     // @see \Drupal\Core\Field\FieldDefinitionInterface
27     /** \Drupal\field\FieldConfigInterface $entity */
28     $field_storage_entity = $entity->getFieldStorageDefinition();
29     return $field_storage_entity->access($operation, $account, TRUE);
30   }
31
32 }