You are here

field_group_easy_responsive_tabs.module in Field Group: Easy Responsive Tabs to Accordion 8

Same filename and directory in other branches
  1. 7 field_group_easy_responsive_tabs.module

File

field_group_easy_responsive_tabs.module
View source
<?php

/**
 * @file
 * Contains field_group_easy_responsive_tabs.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function field_group_easy_responsive_tabs_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the field_group_easy_responsive_tabs module.
    case 'help.page.field_group_easy_responsive_tabs':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Easy Responsive Tabs to Accordion module.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_theme().
 */
function field_group_easy_responsive_tabs_theme() {
  return [
    'field_group_easy_responsive_tabs' => [
      'render element' => 'element',
      'template' => 'field-group-easy-responsive-tabs',
      'file' => 'templates/theme.inc',
    ],
    'field_group_easy_responsive_tab' => [
      'render element' => 'element',
      'template' => 'field-group-easy-responsive-tab',
      'file' => 'templates/theme.inc',
    ],
  ];
}

/**
 * Implements hook_theme_suggestions_alter().
 *
 * @param array $suggestions
 * @param array $variables
 * @param $hook
 */
function field_group_easy_responsive_tabs_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
  switch ($hook) {
    case 'field_group_easy_responsive_tabs':
    case 'field_group_easy_responsive_tab':
      $element = $variables['element'];
      $name = $element['#group_name'];
      $entity_type = $element['#entity_type'];
      $bundle = $element['#bundle'];
      $wrapper = '';
      if (isset($element['#wrapper_element'])) {
        $wrapper = $element['#wrapper_element'];
        $suggestions[] = $hook . '__' . $wrapper;
      }
      $suggestions[] = $hook . '__' . $entity_type;
      $suggestions[] = $hook . '__' . $bundle;
      $suggestions[] = $hook . '__' . $name;
      if ($wrapper) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $wrapper;
      }
      $suggestions[] = $hook . '__' . $entity_type . '__' . $bundle;
      $suggestions[] = $hook . '__' . $entity_type . '__' . $name;
      if ($wrapper) {
        $suggestions[] = $hook . '__' . $entity_type . '__' . $bundle . '__' . $wrapper;
      }
      $suggestions[] = $hook . '__' . $entity_type . '__' . $bundle . '__' . $name;
      break;
  }
}