You are here

function template_preprocess_badge in User Badges 8

Prepares variables for Badge templates.

Default template: badge.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An associative array containing the user information and any
  • attributes: HTML attributes for the containing element.

File

./badge.page.inc, line 22
Contains badge.page.inc..

Code

function template_preprocess_badge(array &$variables) {

  // Fetch Badge Entity Object.
  $badge = $variables['elements']['#badge'];

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