function block_region_permissions_block_access in Block Region Permissions 8
Implements hook_block_access().
File
- ./
block_region_permissions.module, line 110 - Block region permissions module.
Code
function block_region_permissions_block_access(Block $block, $operation, AccountInterface $account) {
// Disallow delete and update permissions if the user cannot administer for
// the selected region.
switch ($operation) {
case 'delete':
case 'update':
$theme_key = $block
->getTheme();
$region_key = $block
->getRegion();
// Skip disabled/none.
if ($region_key != -1) {
// Negate to hide operation link.
return AccessResult::forbiddenIf(!\Drupal::currentUser()
->hasPermission("administer {$theme_key} {$region_key}"));
}
}
}