You are here

function hook_ui_patterns_destination_suggestions_alter in UI Patterns 8

Provide hook theme suggestions for patterns destination wrapper.

A pattern render element having '#multiple_sources' set to TRUE can render multiple sources on the same destination field. Sources will be rendered using the 'patterns_destination' theme function which will use the 'patterns-destination.html.twig' template file.

Developers can take over rendering of the template above by providing proper suggestions, this is useful in case you wish to provide separators or other wrapping elements.

See also

ui_patterns_theme_suggestions_alter()

\Drupal\ui_patterns\Element\Pattern::processMultipleSources()

3 functions implement hook_ui_patterns_destination_suggestions_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

ui_patterns_field_group_ui_patterns_destination_suggestions_alter in modules/ui_patterns_field_group/ui_patterns_field_group.module
Implements hook_ui_patterns_destination_suggestions_alter().
ui_patterns_layouts_ui_patterns_destination_suggestions_alter in modules/ui_patterns_layouts/ui_patterns_layouts.module
Implements hook_ui_patterns_destination_suggestions_alter().
ui_patterns_views_ui_patterns_destination_suggestions_alter in modules/ui_patterns_views/ui_patterns_views.module
Implements hook_ui_patterns_destination_suggestions_alter().
1 invocation of hook_ui_patterns_destination_suggestions_alter()
ui_patterns_theme_suggestions_alter in ./ui_patterns.module
Implements hook_theme_suggestions_HOOK_alter().

File

./ui_patterns.api.php, line 62
API file.

Code

function hook_ui_patterns_destination_suggestions_alter(array &$suggestions, array $variables, PatternContext $context) {
  if ($context
    ->isOfType('views_row')) {
    $hook = $variables['theme_hook_original'];
    $view_name = $context
      ->getProperty('view_name');
    $display = $context
      ->getProperty('display');
    $pattern = $context
      ->getProperty('pattern');
    $field = $context
      ->getProperty('field');
    $suggestions[] = $hook . '__views_row__' . $view_name . '__' . $pattern . '__' . $field;
    $suggestions[] = $hook . '__views_row__' . $view_name . '__' . $display . '__' . $pattern . '__' . $field;
  }
}