file bootstrap.api.php

  1. 8.x-3.x bootstrap.api.php
  2. 7.x-3.x bootstrap.api.php

List of available procedural hook and alter APIs for use in your sub-theme.

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

Functions

Name Description
hook_bootstrap_colorize_text_alter Allows sub-themes to alter the array used for colorizing text.
hook_bootstrap_iconize_text_alter Allows sub-themes to alter the array used for associating an icon with text.