Commit dccc9d31 authored by gbyte.co's avatar gbyte.co

Add some DI

parent 91c2a186
......@@ -51,6 +51,8 @@ services:
simple_sitemap.sitemap_writer:
class: Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapWriter
public: true
arguments:
- '@router.route_provider'
simple_sitemap.entity_helper:
class: Drupal\simple_sitemap\EntityHelper
......
......@@ -2,7 +2,7 @@
namespace Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator;
use Drupal\Core\Url;
use Drupal\Core\Routing\RouteProvider;
/**
* Class SitemapWriter
......@@ -14,6 +14,15 @@ class SitemapWriter extends \XMLWriter {
const XML_VERSION = '1.0';
const ENCODING = 'UTF-8';
/**
* @var \Drupal\Core\Routing\RouteProvider
*/
protected $routeProvider;
public function __construct(RouteProvider $route_provider) {
$this->routeProvider = $route_provider;
}
/**
* Adds the XML stylesheet to the XML page.
*/
......@@ -21,7 +30,7 @@ class SitemapWriter extends \XMLWriter {
// Use this instead of URL::fromRoute() to avoid creating a URL with the
// subdomain from which creation was triggered which might lead to a CORS
// problem. See https://www.drupal.org/project/simple_sitemap/issues/3131672.
$xsl_url = \Drupal::service('router.route_provider')
$xsl_url = $this->routeProvider
->getRouteByName('simple_sitemap.sitemap_xsl')
->getPath();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment