X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fhook%2Fblock_access.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fhook%2Fblock_access.twig;h=970128e1abf79902b6d8caa8565b7fa24efe31fe;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_access.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_access.twig new file mode 100644 index 000000000..970128e1a --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_access.twig @@ -0,0 +1,13 @@ +/** + * Implements hook_block_access(). + */ +function {{ machine_name }}_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(); +}