5 * Hooks provided by the Plugin system.
14 * Alter the filtering of plugin definitions for a specific plugin type.
16 * TYPE (e.g. "block", "layout") limits hook scope to a plugin type.
17 * For example, HOOK_plugin_filter_block_alter() would be invoked
18 * by a hook listener which specifies the 'block' plugin list,
19 * e.g., BlockLibraryController or ChooseBlockController.
21 * @param \Drupal\Component\Plugin\Definition\PluginDefinitionInterface[]|array[] $definitions
22 * The array of plugin definitions.
23 * @param mixed[] $extra
24 * An associative array containing additional information provided by the code
25 * requesting the filtered definitions.
26 * @param string $consumer
27 * A string identifying the consumer of these plugin definitions.
29 function hook_plugin_filter_TYPE_alter(array &$definitions, array $extra, $consumer) {
30 // Remove the "Help" block from the Block UI list.
31 if ($consumer == 'block_ui') {
32 unset($definitions['help_block']);
35 // If the theme is specified, remove the branding block from the Bartik theme.
36 if (isset($extra['theme']) && $extra['theme'] === 'bartik') {
37 unset($definitions['system_branding_block']);
40 // Remove the "Main page content" block from everywhere.
41 unset($definitions['system_main_block']);
45 * Alter the filtering of plugin definitions for a specific type and consumer.
47 * TYPE (e.g. "block", "layout") limits hook scope to a plugin type.
48 * CONSUMER (e.g., "block_ui", "layout_builder") limits hook scope to one or
49 * more listeners, typically provided the same module. For example,
50 * HOOK_plugin_filter_layout__layout_builder_alter() would affect
51 * Layout Builder's listeners for the 'layout' plugin type (see
52 * ChooseSectionController), while HOOK_plugin_filter_block__block_ui_alter()
53 * would affect the Block UI's listeners for the 'block' plugin type.
55 * @param \Drupal\Component\Plugin\Definition\PluginDefinitionInterface[]|array[] $definitions
56 * The array of plugin definitions.
57 * @param mixed[] $extra
58 * An associative array containing additional information provided by the code
59 * requesting the filtered definitions.
61 function hook_plugin_filter_TYPE__CONSUMER_alter(array &$definitions, array $extra) {
62 // Explicitly remove the "Help" block for this consumer.
63 unset($definitions['help_block']);
67 * @} End of "addtogroup hooks".