You are here

function field_group_theme_registry_alter in Field Group 8

Same name and namespace in other branches
  1. 8.3 field_group.module \field_group_theme_registry_alter()
  2. 7.2 field_group.module \field_group_theme_registry_alter()
  3. 7 field_group.module \field_group_theme_registry_alter()

Implements hook_theme_registry_alter().

File

./field_group.module, line 22
Allows administrators to attach custom fields to fieldable types.

Code

function field_group_theme_registry_alter(&$theme_registry) {

  // Inject field_group_build_entity_groups in all entity theming functions.
  $entity_info = Drupal::entityTypeManager()
    ->getDefinitions();
  $entity_types = array();
  foreach ($entity_info as $entity_type_id => $entity_type) {
    if ($route_name = $entity_type
      ->get('field_ui_base_route')) {
      $entity_types[] = $entity_type_id;
    }
  }
  foreach ($theme_registry as $theme_hook => $info) {
    if (in_array($theme_hook, $entity_types) || !empty($info['base hook']) && in_array($info['base hook'], $entity_types)) {
      $theme_registry[$theme_hook]['preprocess functions'][] = 'field_group_build_entity_groups';
    }
  }

  // ECK does not use the eck as theme function.
  if (isset($theme_registry['eck_entity'])) {
    $theme_registry['eck_entity']['preprocess functions'][] = 'field_group_build_entity_groups';
  }
}