function layout_builder_block_content_access in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/layout_builder.module \layout_builder_block_content_access()
- 9 core/modules/layout_builder/layout_builder.module \layout_builder_block_content_access()
Implements hook_ENTITY_TYPE_access().
File
- core/
modules/ layout_builder/ layout_builder.module, line 252 - Provides hook implementations for Layout Builder.
Code
function layout_builder_block_content_access(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\block_content\BlockContentInterface $entity */
if ($operation === 'view' || $entity
->isReusable() || empty(\Drupal::service('inline_block.usage')
->getUsage($entity
->id()))) {
// If the operation is 'view' or this is reusable block or if this is
// non-reusable that isn't used by this module then don't alter the access.
return AccessResult::neutral();
}
if ($account
->hasPermission('create and edit custom blocks')) {
return AccessResult::allowed();
}
return AccessResult::forbidden();
}