annotate core/modules/field/src/FieldConfigAccessControlHandler.php @ 19:fa3358dc1485 tip

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