6110a29a31088fd00c36b6b24b42818a469490f0
[yaffs-website] / web / themes / contrib / bootstrap / bootstrap.api.php
1 <?php
2
3 /**
4  * @file
5  * List of available procedural hook and alter APIs for use in your sub-theme.
6  */
7
8 /**
9  * @addtogroup plugins_alter
10  *
11  * @{
12  */
13
14 /**
15  * Allows sub-themes to alter the array used for colorizing text.
16  *
17  * @param array $texts
18  *   An associative array containing the text and classes to be matched, passed
19  *   by reference.
20  *
21  * @see \Drupal\bootstrap\Bootstrap::cssClassFromString()
22  */
23 function hook_bootstrap_colorize_text_alter(array &$texts) {
24   // This matches the exact string: "My Unique Button Text".
25   // Note: the t() function in D8 returns a TranslatableMarkup object.
26   // It must be rendered to a string before it can be added as an array key.
27   $texts['matches'][t('My Unique Button Text')->render()] = 'primary';
28
29   // This would also match the string above, however the class returned would
30   // also be the one above; "matches" takes precedence over "contains".
31   $texts['contains'][t('Unique')->render()] = 'notice';
32
33   // Remove matching for strings that contain "apply":
34   unset($texts['contains'][t('Apply')->render()]);
35
36   // Change the class that matches "Rebuild" (originally "warning"):
37   $texts['contains'][t('Rebuild')->render()] = 'success';
38 }
39
40 /**
41  * Allows sub-themes to alter the array used for associating an icon with text.
42  *
43  * @param array $texts
44  *   An associative array containing the text and icons to be matched, passed
45  *   by reference.
46  *
47  * @see \Drupal\bootstrap\Bootstrap::glyphiconFromString()
48  */
49 function hook_bootstrap_iconize_text_alter(array &$texts) {
50   // This matches the exact string: "My Unique Button Text".
51   // Note: the t() function in D8 returns a TranslatableMarkup object.
52   // It must be rendered to a string before it can be added as an array key.
53   $texts['matches'][t('My Unique Button Text')->render()] = 'heart';
54
55   // This would also match the string above, however the class returned would
56   // also be the one above; "matches" takes precedence over "contains".
57   $texts['contains'][t('Unique')->render()] = 'bullhorn';
58
59   // Remove matching for strings that contain "filter":
60   unset($texts['contains'][t('Filter')->render()]);
61
62   // Change the icon that matches "Upload" (originally "upload"):
63   $texts['contains'][t('Upload')->render()] = 'ok';
64 }
65
66 /**
67  * @} End of "addtogroup".
68  */