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