You are here

function _sitemap_front_page in Sitemap 8

Helper callback for the sitemap front page.

Return value

array Returns a keyed array with variables for rendering front page sitemap box.

1 call to _sitemap_front_page()
template_preprocess_sitemap in ./sitemap.theme.inc
Preprocesses the variables for sitemap.html.twig.

File

./sitemap.module, line 55
Provides sitemap functionality.

Code

function _sitemap_front_page() {
  $config = \Drupal::config('sitemap.settings');
  $title = t('Front page');
  $content = Link::fromTextAndUrl(t('Front page of %sn', [
    '%sn' => \Drupal::config('system.site')
      ->get('name'),
  ]), Url::fromRoute('<front>', [], [
    'html' => TRUE,
  ]))
    ->toString();
  $attributes = new Attribute();
  $options = [];
  if ($config
    ->get('show_rss_links') != 0) {
    $feed_icon = [
      '#theme' => 'sitemap_feed_icon',
      '#url' => $config
        ->get('rss_front'),
      '#name' => 'front page',
    ];
    $rss_link = \Drupal::service('renderer')
      ->render($feed_icon);
    if ($config
      ->get('show_rss_links') == 1) {
      $content .= ' ' . $rss_link;
    }
    else {
      $attributes
        ->addClass('sitemap-rss-left');
      $content = $rss_link . ' ' . $content;
    }
  }
  \Drupal::service('sitemap.helper')
    ->setOption($options, 'show_titles', 1, 'show_titles', TRUE);
  $attributes
    ->addClass('sitemap-box-front');
  $sitemap_box = [
    'title' => $title,
    'content' => [
      '#markup' => $content,
    ],
    'attributes' => $attributes,
    'options' => $options,
  ];
  return $sitemap_box;
}