You are here

protected function DefaultSitemapGenerator::addAlternateUrl in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php \Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\DefaultSitemapGenerator::addAlternateUrl()

Adds a translation variant URL as alternate URL to a URL.

Parameters

$language_id:

$alternate_url:

1 call to DefaultSitemapGenerator::addAlternateUrl()
DefaultSitemapGenerator::addAlternateUrls in src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php
Adds all translation variant URLs as alternate URLs to a URL.

File

src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php, line 157

Class

DefaultSitemapGenerator
Class DefaultSitemapGenerator @package Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator

Code

protected function addAlternateUrl($language_id, $alternate_url) {
  $this->writer
    ->writeAttribute('rel', 'alternate');
  $this->writer
    ->writeAttribute('hreflang', $language_id);
  $this->writer
    ->writeAttribute('href', $alternate_url);
}