function media_entity_access
Same name in other branches
- 9 core/modules/media/media.module \media_entity_access()
- 8.9.x core/modules/media/media.module \media_entity_access()
Implements hook_entity_access().
File
-
core/
modules/ media/ media.module, line 100
Code
function media_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation === 'delete' && $entity instanceof FieldConfigInterface && $entity->getTargetEntityTypeId() === 'media') {
/** @var \Drupal\media\MediaTypeInterface $media_type */
$media_type = \Drupal::entityTypeManager()->getStorage('media_type')
->load($entity->getTargetBundle());
return AccessResult::forbiddenIf($entity->id() === 'media.' . $media_type->id() . '.' . $media_type->getSource()
->getConfiguration()['source_field']);
}
return AccessResult::neutral();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.