5 * List of available procedural hook and alter APIs for use in your sub-theme.
9 * @addtogroup plugins_alter
15 * Allows sub-themes to alter the array used for colorizing text.
18 * An associative array containing the text and classes to be matched, passed
21 * @see \Drupal\bootstrap\Bootstrap::cssClassFromString()
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';
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';
33 // Remove matching for strings that contain "apply":
34 unset($texts['contains'][t('Apply')->render()]);
36 // Change the class that matches "Rebuild" (originally "warning"):
37 $texts['contains'][t('Rebuild')->render()] = 'success';
41 * Allows sub-themes to alter the array used for associating an icon with text.
44 * An associative array containing the text and icons to be matched, passed
47 * @see \Drupal\bootstrap\Bootstrap::glyphiconFromString()
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';
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';
59 // Remove matching for strings that contain "filter":
60 unset($texts['contains'][t('Filter')->render()]);
62 // Change the icon that matches "Upload" (originally "upload"):
63 $texts['contains'][t('Upload')->render()] = 'ok';
67 * @} End of "addtogroup".