You are here

function template_preprocess_consumer in Consumers 8

Prepares variables for consumer templates.

Default template: consumer.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An array of elements to display in view mode.
  • node: The node object.
  • view_mode: View mode; e.g., 'full', 'teaser', etc.

File

./consumers.module, line 35
Module implementation file.

Code

function template_preprocess_consumer(array &$variables) {
  $variables['client'] = $variables['elements']['#consumer'];
  $variables['view_mode'] = $variables['elements']['#view_mode'];
  $variables['label'] = $variables['elements']['label'];
  $variables['description'] = $variables['elements']['description'];
  $variables['image'] = $variables['elements']['image'];

  // Helpful $content variable for templates.
  $variables += [
    'content' => [],
  ];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}