Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / Plugin / plugin.api.php
1 <?php
2
3 /**
4  * @file
5  * Hooks provided by the Plugin system.
6  */
7
8 /**
9  * @addtogroup hooks
10  * @{
11  */
12
13 /**
14  * Alter the filtering of plugin definitions for a specific plugin type.
15  *
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.
20  *
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.
28  */
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']);
33   }
34
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']);
38   }
39
40   // Remove the "Main page content" block from everywhere.
41   unset($definitions['system_main_block']);
42 }
43
44 /**
45  * Alter the filtering of plugin definitions for a specific type and consumer.
46  *
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.
54  *
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.
60  */
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']);
64 }
65
66 /**
67  * @} End of "addtogroup hooks".
68  */