function MediaLibraryHooks::imageStyleAccess

Same name and namespace in other branches
  1. 11.x core/modules/media_library/src/Hook/MediaLibraryHooks.php \Drupal\media_library\Hook\MediaLibraryHooks::imageStyleAccess()

Implements hook_ENTITY_TYPE_access().

Attributes

#[Hook('image_style_access')]

File

core/modules/media_library/src/Hook/MediaLibraryHooks.php, line 254

Class

MediaLibraryHooks
Hook implementations for media_library.

Namespace

Drupal\media_library\Hook

Code

public function imageStyleAccess(EntityInterface $entity, $operation, AccountInterface $account) : AccessResultInterface {
  // Prevent the fallback 'media_library' image style from being deleted.
  // @todo Lock the image style instead of preventing delete access.
  //   https://www.drupal.org/project/drupal/issues/2247293
  if ($operation === 'delete' && $entity->id() === 'media_library') {
    return AccessResult::forbidden();
  }
  return AccessResult::neutral();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.