function hook_bootstrap_colorize_text_alter

8.x-3.x bootstrap.api.php hook_bootstrap_colorize_text_alter(array &$texts)
7.x-3.x bootstrap.api.php hook_bootstrap_colorize_text_alter(array &$texts)

Allows sub-themes to alter the array used for colorizing text.


array $texts: An associative array containing the text and classes to be matched, passed by reference.

Related topics

1 function implements hook_bootstrap_colorize_text_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

bootstrap_bootstrap_colorize_text_alter in ./bootstrap.theme
1 invocation of hook_bootstrap_colorize_text_alter()
Bootstrap::cssClassFromString in src/Bootstrap.php
Matches a Bootstrap class based on a string value.

Source ./bootstrap.api.php (line 23)

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":

  // Change the class that matches "Rebuild" (originally "warning"):
  $texts['contains'][t('Rebuild')->render()] = 'success';