You are here

public function Frontpage::view in Sitemap 8.2

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Sitemap/Frontpage.php \Drupal\sitemap\Plugin\Sitemap\Frontpage::view()

Builds a renderable array for a sitemap item.

Return value

array A renderable array for a themed field with its label and all its values.

Overrides SitemapInterface::view

File

src/Plugin/Sitemap/Frontpage.php, line 50

Class

Frontpage
Provides a link to the front page for the sitemap.

Namespace

Drupal\sitemap\Plugin\Sitemap

Code

public function view() {
  $title = $this->settings['title'];
  $content[] = [
    '#theme' => 'sitemap_frontpage_item',
    '#text' => $this
      ->t('Front page of %sn', [
      '%sn' => \Drupal::config('system.site')
        ->get('name'),
    ]),
    '#url' => Url::fromRoute('<front>', [], [
      'html' => TRUE,
    ])
      ->toString(),
    '#feed' => $this->settings['rss'],
  ];
  return [
    '#theme' => 'sitemap_item',
    '#title' => $title,
    '#content' => $content,
    '#sitemap' => $this,
  ];
}