You are here

function hook_plugin_filter_TYPE_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/plugin.api.php \hook_plugin_filter_TYPE_alter()
  2. 9 core/lib/Drupal/Core/Plugin/plugin.api.php \hook_plugin_filter_TYPE_alter()

Alter the filtering of plugin definitions for a specific plugin type.

TYPE (e.g. "block", "layout") limits hook scope to a plugin type. For example, HOOK_plugin_filter_block_alter() would be invoked by a hook listener which specifies the 'block' plugin list, e.g., BlockLibraryController or ChooseBlockController.

Parameters

\Drupal\Component\Plugin\Definition\PluginDefinitionInterface[]|array[] $definitions: The array of plugin definitions.

mixed[] $extra: An associative array containing additional information provided by the code requesting the filtered definitions.

string $consumer: A string identifying the consumer of these plugin definitions.

Related topics

6 functions implement hook_plugin_filter_TYPE_alter()

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

layout_builder_plugin_filter_block_alter in core/modules/layout_builder/layout_builder.module
Implements hook_plugin_filter_TYPE_alter().
layout_builder_plugin_filter_block__block_ui_alter in core/modules/layout_builder/layout_builder.module
Implements hook_plugin_filter_TYPE__CONSUMER_alter().
layout_builder_plugin_filter_block__layout_builder_alter in core/modules/layout_builder/layout_builder.module
Implements hook_plugin_filter_TYPE__CONSUMER_alter().
layout_builder_plugin_filter_layout_alter in core/modules/layout_builder/layout_builder.module
Implements hook_plugin_filter_TYPE_alter().
layout_builder_plugin_filter_layout__layout_builder_alter in core/modules/layout_builder/layout_builder.module
Implements hook_plugin_filter_TYPE__CONSUMER_alter().

... See full list

File

core/lib/Drupal/Core/Plugin/plugin.api.php, line 29
Hooks provided by the Plugin system.

Code

function hook_plugin_filter_TYPE_alter(array &$definitions, array $extra, $consumer) {

  // Remove the "Help" block from the Block UI list.
  if ($consumer == 'block_ui') {
    unset($definitions['help_block']);
  }

  // If the theme is specified, remove the branding block from the Bartik theme.
  if (isset($extra['theme']) && $extra['theme'] === 'bartik') {
    unset($definitions['system_branding_block']);
  }

  // Remove the "Main page content" block from everywhere.
  unset($definitions['system_main_block']);
}