function hook_block_alter
Same name and namespace in other branches
- 10 core/modules/block/block.api.php \hook_block_alter()
- 11.x core/modules/block/block.api.php \hook_block_alter()
Allow modules to alter the block plugin definitions.
Parameters
array[] $definitions: The array of block definitions, keyed by plugin ID.
Related topics
18 functions implement hook_block_alter()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- BlockTestHooks::blockAlter in core/
modules/ block/ tests/ modules/ block_test/ src/ Hook/ BlockTestHooks.php - Implements hook_block_alter().
- block_test_block_alter in core/
modules/ block/ tests/ modules/ block_test/ block_test.module - Implements hook_block_alter().
- color_block_view_system_branding_block_alter in core/
modules/ color/ color.module - Implements hook_block_view_BASE_BLOCK_ID_alter().
- help_block_view_help_block_alter in core/
modules/ help/ help.module - Implements hook_block_view_BASE_BLOCK_ID_alter().
- LayoutBuilderFormBlockTestHooks::blockAlter in core/
modules/ layout_builder/ tests/ modules/ layout_builder_form_block_test/ src/ Hook/ LayoutBuilderFormBlockTestHooks.php - Implements hook_block_alter().
File
-
core/
modules/ block/ block.api.php, line 228
Code
function hook_block_alter(&$definitions) {
foreach ($definitions as $id => $definition) {
if (strpos($id, 'system_menu_block:') === 0) {
// Replace $definition properties: id, deriver, class, provider to ones
// provided by this custom module.
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.