public function XmlSitemapWriter::getRootAttributes in XML sitemap 8
Same name and namespace in other branches
- 2.x src/XmlSitemapWriter.php \Drupal\xmlsitemap\XmlSitemapWriter::getRootAttributes()
Return an array of attributes for the root element of the XML.
Return value
array Returns root attributes.
1 call to XmlSitemapWriter::getRootAttributes()
- XmlSitemapWriter::startElement in src/
XmlSitemapWriter.php - Creates start element tag.
File
- src/
XmlSitemapWriter.php, line 148
Class
- XmlSitemapWriter
- Extended class for writing XML sitemap files.
Namespace
Drupal\xmlsitemapCode
public function getRootAttributes() {
$attributes['xmlns'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
// @todo Should content_moderation implement hook_xmlsitemap_root_attributes_alter() instead?
$attributes['xmlns:xhtml'] = 'http://www.w3.org/1999/xhtml';
if (\Drupal::state()
->get('xmlsitemap_developer_mode')) {
$attributes['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
$attributes['xsi:schemaLocation'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
if ($this
->isIndex()) {
$attributes['xsi:schemaLocation'] .= ' http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd';
}
else {
$attributes['xsi:schemaLocation'] .= ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd';
}
}
\Drupal::moduleHandler()
->alter('xmlsitemap_root_attributes', $attributes, $this->sitemap);
return $attributes;
}