SitemapWriter.php in Simple XML sitemap 8.3
File
src/Plugin/simple_sitemap/SitemapGenerator/SitemapWriter.php
View source
<?php
namespace Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator;
use Drupal\Core\Routing\RouteProviderInterface;
class SitemapWriter extends \XMLWriter {
const GENERATED_BY = 'Generated by the Simple XML Sitemap Drupal module: https://drupal.org/project/simple_sitemap.';
const XML_VERSION = '1.0';
const ENCODING = 'UTF-8';
protected $routeProvider;
public function __construct(RouteProviderInterface $route_provider) {
$this->routeProvider = $route_provider;
}
public function writeXsl() {
$xsl_url = $this->routeProvider
->getRouteByName('simple_sitemap.sitemap_xsl')
->getPath();
$xsl_url = base_path() . ltrim($xsl_url, '/');
$this
->writePI('xml-stylesheet', 'type="text/xsl" href="' . $xsl_url . '"');
}
public function writeGeneratedBy() {
$this
->writeComment(self::GENERATED_BY);
}
public function startSitemapDocument() {
$this
->startDocument(self::XML_VERSION, self::ENCODING);
}
}
Classes
Name |
Description |
SitemapWriter |
Class SitemapWriter
@package Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator |