function restrict_ip_block_access in Restrict IP 8
Same name and namespace in other branches
- 8.2 restrict_ip.module \restrict_ip_block_access()
- 3.x restrict_ip.module \restrict_ip_block_access()
Implementation of hook_block_access()
Blocks access to all blocks except the system_main_block if the user does not have access to the current page.
File
- ./
restrict_ip.module, line 14
Code
function restrict_ip_block_access(BlockInterface $block, $operation, AccountInterface $account) {
if ($operation == 'view') {
if (\Drupal::service('restrict_ip.service')
->userIsBlocked()) {
if ($block
->getPluginId() != 'system_main_block') {
return AccessResult::forbidden();
}
}
}
return AccessResult::neutral();
}