You are here

protected function DefaultSitemapGenerator::addAlternateUrl in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 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

string $language_id:

string $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 151

Class

DefaultSitemapGenerator
Class DefaultSitemapGenerator

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator

Code

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