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