function hook_block_access(\Drupal\block\Entity\Block
$block,
$operation, \Drupal\Core\Session\AccountInterface
$account) { // Example code that would prevent displaying the 'Powered by Drupal' block in
// a region different than the footer.
if ($operation == 'view' &&
$block->
getPluginId() == 'system_powered_by_block'
) { return AccessResult::
forbiddenIf($block->
getRegion() != 'footer'
)->
addCacheableDependency($block);
} // No opinion.
return AccessResult::
neutral();
}/**
* Allow modules to alter the block plugin definitions.
*
* @param array[] $definitions
* The array of block definitions, keyed by plugin ID.
*
* @ingroup block_api
*/