You are here

function template_preprocess_site_map_feed_icon in Site map 8

Preprocesses variables for site-map-feed-icon.html.twig.

Parameters

array $variables: An associative array containing:

  • url: The url of the feed.
  • name: The name of the feed.
  • type: The type of feed icon.

Return value

array $variables

File

./site_map.theme.inc, line 45
Site map theme functions.

Code

function template_preprocess_site_map_feed_icon(array &$variables) {
  $output = '';
  switch ($variables['type']) {
    case 'node':
      $image = array(
        '#theme' => 'image',
        '#uri' => drupal_get_path('module', 'site_map') . '/images/feed-small.png',
        '#title' => t('Syndicated feed icon'),
        '#alt' => t('Syndicated feed icon'),
      );
      $output = drupal_render($image);
      break;
    case 'comment':
      $image = array(
        '#theme' => 'image',
        '#uri' => drupal_get_path('module', 'site_map') . '/images/feed-small-comment.png',
        '#title' => t('Syndicated feed icon'),
        '#alt' => t('Syndicated feed icon'),
      );
      $output = drupal_render($image);
      break;
  }
  if (!empty($variables['url'])) {
    $output = \Drupal::l($output, Url::fromUri('base://' . $variables['url'], array(
      'attributes' => array(
        'class' => 'feed-link',
        'title' => t('Syndicated feed for') . ' ' . $variables['name'],
      ),
      'html' => TRUE,
    )));
  }
  $variables['icon'] = $output;
}