2 * Implements hook_block_access().
4 function {{ machine_name }}_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
5 // Example code that would prevent displaying the 'Powered by Drupal' block in
6 // a region different than the footer.
7 if ($operation == 'view' && $block->getPluginId() == 'system_powered_by_block') {
8 return AccessResult::forbiddenIf($block->getRegion() != 'footer')->addCacheableDependency($block);
12 return AccessResult::neutral();