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