Commit 290ceb42 authored by webchick's avatar webchick
Browse files

Issue #1892472 by pcambra: Document hook_block_access().

parent 0038f2a9
......@@ -98,6 +98,30 @@ function hook_block_view_NAME_alter(array &$build, \Drupal\block\BlockInterface
$build['#title'] = t('New title of the block');
}
/**
* Define access for a specific block instance.
*
* This hook is invoked by the access methods of the block plugin system and
* should be used to alter the block access rules defined by a module from
* another module.
*
* @param \Drupal\block\Plugin\Core\Entity\Block $block
* The block instance.
*
* @return bool
* TRUE will allow access whereas FALSE will deny access to the block.
*
* @see \Drupal\block\BlockBase::access()
* @see \Drupal\block\BlockBase::blockAccess()
*/
function hook_block_access(\Drupal\block\Plugin\Core\Entity\Block $block) {
// Example code that would prevent displaying the 'Powered by Drupal' block in
// a region different than the footer.
if ($block->get('plugin') == 'system_powered_by_block' && $block->get('region') != 'footer') {
return FALSE;
}
}
/**
* @} End of "addtogroup hooks".
*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment