You are here

function ui_patterns_layouts_ui_patterns_suggestions_alter in UI Patterns 8

Implements hook_ui_patterns_suggestions_alter().

File

modules/ui_patterns_layouts/ui_patterns_layouts.module, line 76
Contains module file.

Code

function ui_patterns_layouts_ui_patterns_suggestions_alter(array &$suggestions, array $variables, PatternContext $context) {
  if ($context
    ->isOfType('layout')) {
    $hook = $variables['theme_hook_original'];
    $variant = isset($variables["variant"]) ? $variables["variant"] : '';
    $entity_type = $context
      ->getProperty('entity_type');
    $bundle = $context
      ->getProperty('bundle');
    $view_mode = $context
      ->getProperty('view_mode');
    $entity_id = $context
      ->getProperty('entity_id');
    $suggestions[] = $hook . '__layout';
    $suggestions[] = $hook . '__layout__' . $entity_type;
    $suggestions[] = $hook . '__layout__' . $entity_type . '__' . $bundle;
    $suggestions[] = $hook . '__layout__' . $entity_type . '__' . $view_mode;
    $suggestions[] = $hook . '__layout__' . $entity_type . '__' . $bundle . '__' . $view_mode;
    $suggestions[] = $hook . '__layout__' . $entity_type . '__' . $entity_id;
    if (!empty($variant)) {
      $suggestions[] = $hook . '__variant_' . $variant . '__layout';
      $suggestions[] = $hook . '__variant_' . $variant . '__layout__' . $entity_type;
      $suggestions[] = $hook . '__variant_' . $variant . '__layout__' . $entity_type . '__' . $bundle;
      $suggestions[] = $hook . '__variant_' . $variant . '__layout__' . $entity_type . '__' . $view_mode;
      $suggestions[] = $hook . '__variant_' . $variant . '__layout__' . $entity_type . '__' . $bundle . '__' . $view_mode;
      $suggestions[] = $hook . '__variant_' . $variant . '__layout__' . $entity_type . '__' . $entity_id;
    }
  }
}