theme.inc 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @file
  4. * Preprocessors for fieldgroup elements.
  5. */
  6. /**
  7. * Prepares variables for horizontal tabs templates.
  8. *
  9. * Default template: horizontal-tabs.html.twig.
  10. *
  11. * @param array $variables
  12. * An associative array containing:
  13. * - element: An associative array containing the properties and children of
  14. * the details element. Properties used: #children.
  15. *
  16. */
  17. function template_preprocess_horizontal_tabs(&$variables) {
  18. $element = $variables['element'];
  19. $variables['children'] = (!empty($element['#children'])) ? $element['#children'] : '';
  20. }
  21. /**
  22. * Prepares variables for fieldgroup accordion templates.
  23. *
  24. * Default template: field-group-accordion.html.twig.
  25. *
  26. * @param array $variables
  27. * An associative array containing:
  28. * - element: An associative array containing the properties and children of
  29. * the accordion element. Properties used: #children.
  30. *
  31. */
  32. function template_preprocess_field_group_accordion(&$variables) {
  33. $element = $variables['element'];
  34. $variables['children'] = (!empty($element['#children'])) ? $element['#children'] : '';
  35. }
  36. /**
  37. * Prepares variables for fieldgroup accordion item templates.
  38. *
  39. * Default template: field-group-accordion-item.html.twig.
  40. *
  41. * @param array $variables
  42. * An associative array containing:
  43. * - element: An associative array containing the properties and children of
  44. * the accordion item element.
  45. *
  46. */
  47. function template_preprocess_field_group_accordion_item(&$variables) {
  48. $element = $variables['element'];
  49. if (!empty($element['#title'])) {
  50. $variables['title'] = $element['#title'];
  51. }
  52. if (!empty($element['#description'])) {
  53. $variables['description'] = $element['#description'];
  54. }
  55. $variables['open'] = $element['#open'];
  56. $variables['label_attributes'] = new \Drupal\Core\Template\Attribute();
  57. $variables['children'] = (!empty($element['#children'])) ? $element['#children'] : '';
  58. }
  59. /**
  60. * Prepares variables for fieldgroup html element templates.
  61. *
  62. * Default template: field-group-html-element.html.twig.
  63. *
  64. * @param array $variables
  65. * An associative array containing:
  66. * - element: An associative array containing the properties and children of
  67. * the html element.
  68. *
  69. */
  70. function template_preprocess_field_group_html_element(&$variables) {
  71. $element = $variables['element'];
  72. if (!empty($element['#title']) && !empty($element['#title_element'])) {
  73. $variables['title_element'] = $element['#title_element'];
  74. $variables['title'] = $element['#title'];
  75. }
  76. $variables['collapsible'] = (!empty($element['#effect']) && $element['#effect'] !== 'none');
  77. $variables['wrapper_element'] = $element['#wrapper_element'];
  78. $variables['attributes'] = $element['#attributes'];
  79. $variables['children'] = (!empty($element['#children'])) ? $element['#children'] : '';
  80. }