You are here

function hook_block_alter in Drupal 9

Allow modules to alter the block plugin definitions.

Parameters

array[] $definitions: The array of block definitions, keyed by plugin ID.

Related topics

11 functions implement hook_block_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

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().
layout_builder_plugin_filter_block_alter in core/modules/layout_builder/layout_builder.module
Implements hook_plugin_filter_TYPE_alter().
layout_builder_test_form_layout_builder_configure_block_alter in core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module
Implements hook_form_BASE_FORM_ID_alter() for layout_builder_configure_block.

... See full list

File

core/modules/block/block.api.php, line 227
Hooks provided by the Block module.

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.
    }
  }
}