You are here

protected function DefaultSitemapGenerator::addSitemapAttributes 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::addSitemapAttributes()

Adds attributes to the sitemap.

1 call to DefaultSitemapGenerator::addSitemapAttributes()
DefaultSitemapGenerator::getChunkXml in src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php
Generates and returns a sitemap chunk.

File

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

Class

DefaultSitemapGenerator
Class DefaultSitemapGenerator

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator

Code

protected function addSitemapAttributes() : void {
  $attributes = self::ATTRIBUTES;
  if (!$this->sitemapVariant
    ->isMultilingual()) {
    unset($attributes['xmlns:xhtml']);
  }
  $sitemap_variant = $this->sitemapVariant
    ->id();
  $this->moduleHandler
    ->alter('simple_sitemap_attributes', $attributes, $sitemap_variant);
  foreach ($attributes as $name => $value) {
    $this->writer
      ->writeAttribute($name, $value);
  }
}