You are here

function field_group_theme_suggestions_alter in Field Group 8.3

Same name and namespace in other branches
  1. 8 field_group.module \field_group_theme_suggestions_alter()

Implements hook_theme_suggestions_alter().

File

./field_group.module, line 116
Allows administrators to attach field groups.

Code

function field_group_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
  switch ($hook) {
    case 'horizontal_tabs':
    case 'field_group_accordion_item':
    case 'field_group_accordion':
    case 'field_group_html_element':
      $element = $variables['element'];
      $name = !empty($element['#group_name']) ? $element['#group_name'] : NULL;
      $entity_type = !empty($element['#entity_type']) ? $element['#entity_type'] : NULL;
      $bundle = !empty($element['#bundle']) ? $element['#bundle'] : NULL;
      $wrapper = '';
      if (isset($element['#wrapper_element'])) {
        $wrapper = $element['#wrapper_element'];
        $suggestions[] = $hook . '__' . $wrapper;
      }
      if (!empty($entity_type)) {
        $suggestions[] = $hook . '__' . $entity_type;
      }
      if (!empty($bundle)) {
        $suggestions[] = $hook . '__' . $bundle;
      }
      if (!empty($name)) {
        $suggestions[] = $hook . '__' . $name;
      }
      if ($wrapper && !empty($entity_type)) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $wrapper;
      }
      if (!empty($entity_type) && !empty($bundle)) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $bundle;
      }
      if (!empty($entity_type) && !empty($name)) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $name;
      }
      if ($wrapper && !empty($entity_type) && !empty($bundle)) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $bundle . '__' . $wrapper;
      }
      if (!empty($entity_type) && !empty($bundle) && !empty($name)) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $bundle . '__' . $name;
      }
      break;
  }
}