You are here

function entity_extra_field_theme_suggestions_entity_extra_field in Entity Extra Field 8

Same name and namespace in other branches
  1. 2.0.x entity_extra_field.module \entity_extra_field_theme_suggestions_entity_extra_field()

Implements hook_theme_suggestions_HOOK().

File

./entity_extra_field.module, line 164
The hook implementation for the entity extra field module.

Code

function entity_extra_field_theme_suggestions_entity_extra_field(array $variables) {
  $original = $variables['theme_hook_original'];
  $view_mode = $variables['element']['#view_mode'];
  $field = $variables['element']['#field'];
  $entity_type_id = $field
    ->getBaseEntityTypeId();
  $bundle_id = $field
    ->getBaseBundleTypeId();
  $field_name = $field
    ->name();
  $base_suggestion = $original . '__' . $entity_type_id . '__' . $bundle_id;
  $suggestions = [];
  $suggestions[] = $base_suggestion;
  $suggestions[] = $base_suggestion . '__' . $field_name;
  $suggestions[] = $base_suggestion . '__' . $field_name . '__' . $view_mode;
  return $suggestions;
}