FieldConfigAccessControlHandler.php 1.2 KB

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