$entity_type,
$container->
get('event_dispatcher'
) );
} /**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface
$entity,
$operation, AccountInterface
$account) { assert($entity instanceof BlockContentInterface
);
$bundle =
$entity->
bundle();
$forbidIfNotDefaultAndLatest =
fn (): AccessResultInterface => AccessResult::
forbiddenIf($entity->
isDefaultRevision() &&
$entity->
isLatestRevision());
$forbidIfNotReusable =
fn (): AccessResultInterface => AccessResult::
forbiddenIf($entity->
isReusable() === FALSE,
sprintf('Block content must be reusable to use `%s` operation',
$operation));
$access =
match ($operation) { // Allow view and update access to user with the 'edit any (type) block
// content' permission or the 'administer blocks' permission.
'view' => AccessResult::
allowedIf($entity->
isPublished()) ->
orIf(AccessResult::
allowedIfHasPermissions($account,
[ 'access block library',
]))->
orIf(AccessResult::
allowedIfHasPermissions($account,
[ 'administer block content',
])),
'update' => AccessResult::
allowedIfHasPermissions($account,
[