You are here

function template_preprocess_linkicon in Link Icon 8

Prepares variables for linkicon templates.

Default template: linkicon.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #items, #config, #attributes.

    • items: An array of items containing links with icon formatted.
    • config: An array of settings that decides the link icon output.
    • attributes: An associative array of attributes placed in the UL tag.

File

./linkicon.theme.inc, line 24
Preprocessors and theme functions of Linkicon module.

Code

function template_preprocess_linkicon(array &$variables) {
  $element = $variables['element'];
  $variables['wrapper_attributes'] = new Attribute();
  $variables['attributes'] = isset($element['#attributes']) ? new Attribute($element['#attributes']) : [];
  $variables['settings'] = $element['#config'];
  $variables['items'] = $element['#items'];
  $variables['label'] = isset($element['#title']) ? $element['#title'] : '';
  $variables['_preview'] = !empty($variables['settings']['_preview']);
  foreach ([
    'field_name',
    'field_type',
    'label_display',
  ] as $key) {
    $variables[$key] = isset($element["#{$key}"]) ? $element["#{$key}"] : '';
  }
  if (!empty($element['#linkicon_id'])) {
    $variables['attributes']['id'] = $element['#linkicon_id'];
  }
}