You are here

function _commerce_entity_theme_suggestions in Commerce Core 8.2

Helper for providing entity theme suggestions.

Parameters

string $entity_type_id: The entity type ID.

array $variables: An array of variables passed to the theme hook.

Return value

array An array of theme suggestions.

8 calls to _commerce_entity_theme_suggestions()
commerce_order_theme_suggestions_commerce_order in modules/order/commerce_order.module
Implements hook_theme_suggestions_commerce_order().
commerce_order_theme_suggestions_commerce_order_item in modules/order/commerce_order.module
Implements hook_theme_suggestions_commerce_order_item().
commerce_payment_theme_suggestions_commerce_payment_method in modules/payment/commerce_payment.module
Implements hook_theme_suggestions_commerce_payment_method().
commerce_product_theme_suggestions_commerce_product in modules/product/commerce_product.module
Implements hook_theme_suggestions_commerce_product().
commerce_product_theme_suggestions_commerce_product_attribute_value in modules/product/commerce_product.module
Implements hook_theme_suggestions_commerce_product_commerce_product_attribute_value().

... See full list

File

./commerce.module, line 194
Defines common functionality for all Commerce modules.

Code

function _commerce_entity_theme_suggestions($entity_type_id, array $variables) {
  $original = $variables['theme_hook_original'];
  $entity = $variables['elements']['#' . $entity_type_id];
  $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
  $suggestions = [];
  $suggestions[] = $original . '__' . $sanitized_view_mode;
  $suggestions[] = $original . '__' . $entity
    ->bundle();
  $suggestions[] = $original . '__' . $entity
    ->bundle() . '__' . $sanitized_view_mode;
  $suggestions[] = $original . '__' . $entity
    ->id();
  $suggestions[] = $original . '__' . $entity
    ->id() . '__' . $sanitized_view_mode;
  return $suggestions;
}