annotate vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_access.twig @ 5:12f9dff5fda9
tip
Update to Drupal core 8.7.1
author |
Chris Cannam |
date |
Thu, 09 May 2019 15:34:47 +0100 |
parents |
c75dbcec494b |
children |
|
rev |
line source |
Chris@0
|
1 /**
|
Chris@0
|
2 * Implements hook_block_access().
|
Chris@0
|
3 */
|
Chris@0
|
4 function {{ machine_name }}_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
|
Chris@0
|
5 // Example code that would prevent displaying the 'Powered by Drupal' block in
|
Chris@0
|
6 // a region different than the footer.
|
Chris@0
|
7 if ($operation == 'view' && $block->getPluginId() == 'system_powered_by_block') {
|
Chris@0
|
8 return AccessResult::forbiddenIf($block->getRegion() != 'footer')->addCacheableDependency($block);
|
Chris@0
|
9 }
|
Chris@0
|
10
|
Chris@0
|
11 // No opinion.
|
Chris@0
|
12 return AccessResult::neutral();
|
Chris@0
|
13 }
|