Unverified Commit a9490a18 authored by Dave Reid's avatar Dave Reid Committed by Dave Reid

Issue #3002605 by Dave Reid: Refactor XmlSitemapWriter to not reverse call...

Issue #3002605 by Dave Reid: Refactor XmlSitemapWriter to not reverse call XmlSitemapGenerator. Removed XmlSitemapIndexWriter.
parent 24882844
......@@ -4,6 +4,8 @@ namespace Drupal\xmlsitemap;
use Drupal\Component\Utility\Bytes;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
......@@ -79,6 +81,20 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
*/
protected $moduleHandler;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* Constructs a XmlSitemapGenerator object.
*
......@@ -92,20 +108,26 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
* A logger instance.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Database\Connection $connection
* The database connection.
*/
public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state, LanguageManagerInterface $language_manager, LoggerInterface $logger, ModuleHandlerInterface $module_handler) {
public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state, LanguageManagerInterface $language_manager, LoggerInterface $logger, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, Connection $connection) {
$this->config = $config_factory->getEditable('xmlsitemap.settings');
$this->state = $state;
$this->languageManager = $language_manager;
$this->logger = $logger;
$this->moduleHandler = $module_handler;
$this->entityTypeManager = $entity_type_manager;
$this->connection = $connection;
}
/**
* {@inheritdoc}
*/
public function getPathAlias($path, $language) {
$query = db_select('url_alias', 'u');
$query = $this->connection->select('url_alias', 'u');
$query->fields('u', ['source', 'alias']);
if (!isset(static::$aliases)) {
$query->condition('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED, '=');
......@@ -171,7 +193,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
// Add memory for storing the url aliases.
if ($this->config->get('prefetch_aliases')) {
$aliases = db_query("SELECT COUNT(pid) FROM {url_alias}")->fetchField();
$aliases = $this->connection->query("SELECT COUNT(pid) FROM {url_alias}")->fetchField();
$optimal_limit += $aliases * 250;
}
}
......@@ -197,17 +219,10 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
* {@inheritdoc}
*/
public function generatePage(XmlSitemapInterface $sitemap, $page) {
try {
$writer = new XmlSitemapWriter($sitemap, $page);
$writer->startDocument();
$writer->generateXML();
$writer->endDocument();
}
catch (Exception $e) {
$this->logger->error($e);
throw $e;
}
$writer = new XmlSitemapWriter($sitemap, $page);
$writer->startDocument();
$this->generateChunk($sitemap, $writer, $page);
$writer->endDocument();
return $writer->getSitemapElementCount();
}
......@@ -230,7 +245,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
$last_url = '';
$link_count = 0;
$query = db_select('xmlsitemap', 'x');
$query = $this->connection->select('xmlsitemap', 'x');
$query->fields('x', [
'loc', 'type', 'subtype', 'lastmod', 'changefreq', 'changecount', 'priority', 'language', 'access', 'status',
]);
......@@ -308,18 +323,38 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
/**
* {@inheritdoc}
*/
public function generateIndex(XmlSitemapInterface $sitemap) {
try {
$writer = new XmlSitemapIndexWriter($sitemap);
$writer->startDocument();
$writer->generateXML();
$writer->endDocument();
public function generateIndex(XmlSitemapInterface $sitemap, $pages = NULL) {
$writer = new XmlSitemapWriter($sitemap, 'index');
$writer->startDocument();
$lastmod_format = $this->config->get('lastmod_format');
$url_options = $sitemap->uri['options'];
$url_options += [
'absolute' => TRUE,
'xmlsitemap_base_url' => $this->state->get('xmlsitemap_base_url'),
'language' => $this->languageManager->getDefaultLanguage(),
'alias' => TRUE,
];
if (!isset($pages)) {
$pages = $sitemap->getChunks();
}
catch (Exception $e) {
$this->logger->error($e);
throw $e;
for ($current_page = 1; $current_page <= $pages; $current_page++) {
$url_options['query']['page'] = $current_page;
$element = [
'loc' => Url::fromRoute('xmlsitemap.sitemap_xml', [], $url_options)->toString(),
// @todo Use the actual lastmod value of the chunk file.
'lastmod' => gmdate($lastmod_format, REQUEST_TIME),
];
// @todo SHould the element be altered?
$writer->writeSitemapElement('sitemap', $element);
}
$writer->endDocument();
return $writer->getSitemapElementCount();
}
......@@ -328,8 +363,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
*/
public function regenerateBatchGenerate($smid, array &$context) {
if (!isset($context['sandbox']['sitemap'])) {
$sitemap = xmlsitemap_sitemap_load($smid);
$context['sandbox']['sitemap'] = $sitemap;
$context['sandbox']['sitemap'] = $this->entityTypeManager->getStorage('xmlsitemap')->load($smid);
$context['sandbox']['sitemap']->setChunks(1);
$context['sandbox']['sitemap']->setLinks(0);
$context['sandbox']['max'] = XMLSITEMAP_MAX_SITEMAP_LINKS;
......@@ -338,13 +372,23 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
xmlsitemap_check_directory($context['sandbox']['sitemap']);
xmlsitemap_clear_directory($context['sandbox']['sitemap']);
}
/** @var \Drupal\xmlsitemap\XmlSitemapInterface $sitemap */
$sitemap = &$context['sandbox']['sitemap'];
$links = $this->generatePage($sitemap, $sitemap->getChunks());
$context['message'] = t('Now generating %sitemap-url.', [
try {
$links = $this->generatePage($sitemap, $sitemap->getChunks());
}
catch (\Exception $e) {
// @todo Should this use watchdog_exception()?
$this->logger->error($e);
}
$context['message'] = t('Generated %sitemap-url.', [
'%sitemap-url' => Url::fromRoute('xmlsitemap.sitemap_xml', [], $sitemap->uri['options'] + ['query' => ['page' => $sitemap->getChunks()]])->toString(),
]);
if ($links) {
if (!empty($links)) {
$sitemap->setLinks($sitemap->getLinks() + $links);
$sitemap->setChunks($sitemap->getChunks() + 1);
}
......@@ -361,9 +405,12 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
$sitemap->setUpdated(REQUEST_TIME);
xmlsitemap_sitemap_get_max_filesize($sitemap);
xmlsitemap_sitemap_save($sitemap);
$context['finished'] = 1;
return;
}
if ($sitemap->getChunks() != $context['sandbox']['max']) {
if ($sitemap->getChunks() < $context['sandbox']['max']) {
$context['finished'] = $sitemap->getChunks() / $context['sandbox']['max'];
}
}
......@@ -372,9 +419,16 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
* {@inheritdoc}
*/
public function regenerateBatchGenerateIndex($smid, array &$context) {
$sitemap = xmlsitemap_sitemap_load($smid);
/** @var \Drupal\xmlsitemap\XmlSitemapInterface $sitemap */
$sitemap = $this->entityTypeManager->getStorage('xmlsitemap')->load($smid);
if ($sitemap != NULL && $sitemap->getChunks() > 1) {
$this->generateIndex($sitemap);
try {
$this->generateIndex($sitemap);
}
catch (\Exception $e) {
// @todo Should this use watchdog_exception()?
$this->logger->error($e);
}
$context['message'] = t('Now generating sitemap index %sitemap-url.', [
'%sitemap-url' => Url::fromRoute('xmlsitemap.sitemap_xml', [], $sitemap->uri['options'])->toString(),
]);
......@@ -384,7 +438,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
/**
* {@inheritdoc}
*/
public function regenerateBatchFinished($success, $results, $operations, $elapsed) {
public function regenerateBatchFinished($success, array $results, array $operations, $elapsed) {
if ($success && $this->state->get('xmlsitemap_regenerate_needed') == FALSE) {
$this->state->set('xmlsitemap_generated_last', REQUEST_TIME);
drupal_set_message(t('The sitemaps were regenerated.'));
......@@ -437,9 +491,9 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
}
$info = $context['sandbox']['info'];
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$query = \Drupal::entityQuery($entity_type_id);
$query = $this->entityTypeManager->getStorage($entity_type_id)->getQuery();
$query->condition($entity_type->getKey('id'), $context['sandbox']['last_id'], '>');
if ($entity_type->hasKey('bundle')) {
$query->condition($entity_type->getKey('bundle'), $context['sandbox']['bundles'], 'IN');
......@@ -489,7 +543,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
/**
* {@inheritdoc}
*/
public function rebuildBatchFinished($success, $results, $operations, $elapsed) {
public function rebuildBatchFinished($success, array $results, array $operations, $elapsed) {
if ($success && !\Drupal::state()->get('xmlsitemap_rebuild_needed', FALSE)) {
drupal_set_message(t('The sitemap links were rebuilt.'));
}
......
......@@ -71,7 +71,7 @@ interface XmlSitemapGeneratorInterface {
* Generates one chunk of the sitemap.
*
* @param \Drupal\xmlsitemap\XmlSitemapInterface $sitemap
* An unserialized data array for an XML sitemap.
* The XML sitemap config entity.
* @param \Drupal\xmlsitemap\XmlSitemapWriter $writer
* XML writer object.
* @param int $chunk
......@@ -82,10 +82,13 @@ interface XmlSitemapGeneratorInterface {
/**
* Generate the index sitemap.
*
* @param XmlSitemapInterface $sitemap
* An unserialized data array for an XML sitemap.
* @param \Drupal\xmlsitemap\XmlSitemapInterface $sitemap
* The XML sitemap config entity.
* @param int|null $pages
* The number of pages to write in the sitemap. Defaults to the value of
* @code $sitemap->getChunks() @endcode.
*/
public function generateIndex(XmlSitemapInterface $sitemap);
public function generateIndex(XmlSitemapInterface $sitemap, $pages = NULL);
/**
* Batch callback; generate all pages of a sitemap.
......@@ -119,10 +122,8 @@ interface XmlSitemapGeneratorInterface {
* @param int $elapsed
* Elapsed.
* Time elapsed.
*
* @codingStandardsIgnoreStart
*/
public function regenerateBatchFinished($success, $results, $operations, $elapsed);
public function regenerateBatchFinished($success, array $results, array $operations, $elapsed);
/**
* Batch callback; clear sitemap links for entites.
......@@ -159,15 +160,13 @@ interface XmlSitemapGeneratorInterface {
* Elapsed.
* Time elapsed.
*/
public function rebuildBatchFinished($success, $results, $operations, $elapsed);
public function rebuildBatchFinished($success, array $results, array $operations, $elapsed);
/**
* Set variables during the batch process.
*
* @param array $variables
* Variables to be set.
*
* @codingStandardsIgnoreEnd
*/
public function batchVariableSet(array $variables);
......
<?php
namespace Drupal\xmlsitemap;
use Drupal\Core\Url;
/**
* Extended class for writing XML sitemap indexes.
*/
class XmlSitemapIndexWriter extends XmlSitemapWriter {
/**
* Name of the root element of the document.
*
* @var string
*/
protected $rootElement = 'sitemapindex';
/**
* {@inheritdoc}
*/
public function __construct(XmlSitemapInterface $sitemap, $page = 'index') {
parent::__construct($sitemap, 'index');
}
/**
* {@inheritdoc}
*
* @todo Should this call parent::getRootAttributes()?
*/
public function getRootAttributes() {
$attributes['xmlns'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
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 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd';
}
\Drupal::moduleHandler()->alter('xmlsitemap_root_attributes', $attributes, $this->sitemap);
return $attributes;
}
/**
* {@inheritdoc}
*
* @codingStandardsIgnoreStart
*/
public function generateXML() {
// @codingStandardsIgnoreEnd
$lastmod_format = \Drupal::config('xmlsitemap.settings')->get('lastmod_format');
$url_options = $this->sitemap->uri['options'];
$url_options += [
'absolute' => TRUE,
'xmlsitemap_base_url' => \Drupal::state()->get('xmlsitemap_base_url'),
'language' => \Drupal::languageManager()->getDefaultLanguage(),
'alias' => TRUE,
];
for ($i = 1; $i <= $this->sitemap->chunks; $i++) {
$url_options['query']['page'] = $i;
$element = [
'loc' => Url::fromRoute('xmlsitemap.sitemap_xml', [], $url_options)->toString(),
// @todo Use the actual lastmod value of the chunk file.
'lastmod' => gmdate($lastmod_format, REQUEST_TIME),
];
$this->writeSitemapElement('sitemap', $element);
}
}
}
......@@ -66,6 +66,7 @@ class XmlSitemapStorage extends ConfigEntityStorage {
// Delete the auxiliar xmlsitemap data.
foreach ($entities as $entity) {
$this->state->delete('xmlsitemap.' . $entity->id());
xmlsitemap_clear_directory($entity, TRUE);
}
parent::doDelete($entities);
......@@ -89,6 +90,9 @@ class XmlSitemapStorage extends ConfigEntityStorage {
foreach ($settings as $setting => $value) {
$entity->{$setting} = $value;
}
// Load the entity URI.
$entity->uri = xmlsitemap_sitemap_uri($entity);
}
return $entities;
......
......@@ -35,36 +35,26 @@ class XmlSitemapWriter extends \XMLWriter {
*
* @var \Drupal\xmlsitemap\XmlSitemapInterface
*/
protected $sitemap = NULL;
protected $sitemap;
/**
* Sitemap page to be written.
*
* @var string
*
* @codingStandardsIgnoreStart
* @var int|string
*/
protected $sitemap_page = NULL;
// @codingStandardsIgnoreEnd
/**
* Name of the root element of the document.
*
* @var string
*/
protected $rootElement = 'urlset';
protected $page;
/**
* Constructors and XmlSitemapWriter object.
*
* @param \Drupal\xmlsitemap\XmlSitemapInterface $sitemap
* The sitemap array.
* @param string $page
* The XML sitemap.
* @param int|string $page
* The current page of the sitemap being generated.
*/
public function __construct(XmlSitemapInterface $sitemap, $page) {
$this->sitemap = $sitemap;
$this->sitemap_page = $page;
$this->page = $page;
$this->uri = xmlsitemap_sitemap_get_file($sitemap, $page);
$this->openUri($this->uri);
}
......@@ -75,11 +65,11 @@ class XmlSitemapWriter extends \XMLWriter {
* @param string $uri
* Uri to be opened.
*
* @throws XmlSitemapGenerationException
* Throws exception when uri cannot be opened.
*
* @return bool
* Returns TRUE when uri was successful opened.
* Returns TRUE when uri was successfully opened.
*
* @throws XmlSitemapGenerationException
* If the file URI cannot be opened.
*/
public function openUri($uri) {
$return = parent::openUri($uri);
......@@ -114,7 +104,7 @@ class XmlSitemapWriter extends \XMLWriter {
if (\Drupal::config('xmlsitemap.settings')->get('xsl')) {
$this->writeXSL();
}
$this->startElement($this->rootElement, TRUE);
$this->startElement($this->isIndex() ? 'sitemapindex' : 'urlset', TRUE);
return $result;
}
......@@ -154,7 +144,13 @@ class XmlSitemapWriter extends \XMLWriter {
$attributes['xmlns'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
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 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd';
$attributes['xsi:schemaLocation'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
if ($this->isIndex()) {
$attributes['xsi:schemaLocation'] = ' ' . $attributes['xsi:schemaLocation'] . '/siteindex.xsd';
}
else {
$attributes['xsi:schemaLocation'] = ' ' . $attributes['xsi:schemaLocation'] . '/sitemap.xsd';
}
}
\Drupal::moduleHandler()->alter('xmlsitemap_root_attributes', $attributes, $this->sitemap);
......@@ -162,19 +158,6 @@ class XmlSitemapWriter extends \XMLWriter {
return $attributes;
}
/**
* Generate one chunk of the sitemap.
*
* @return int
* Number of XML elements written.
*
* @codingStandardsIgnoreStart
*/
public function generateXML() {
// @codingStandardsIgnoreEnd
return \Drupal::service('xmlsitemap_generator')->generateChunk($this->sitemap, $this, $this->sitemap_page);
}
/**
* Creates start element tag.
*
......@@ -202,7 +185,7 @@ class XmlSitemapWriter extends \XMLWriter {
* @param array $element
* An array of the elements properties and values.
*/
public function writeSitemapElement($name, array &$element) {
public function writeSitemapElement($name, array $element) {
$this->writeElement($name, $element);
$this->writeRaw(PHP_EOL);
......@@ -219,10 +202,10 @@ class XmlSitemapWriter extends \XMLWriter {
*
* @param string $name
* The element name.
* @param string $content
* @param string|array $content
* The element contents or an array of the elements' sub-elements.
*/
public function writeElement($name, $content = '') {
public function writeElement($name, $content = NULL) {
if (is_array($content)) {
$this->startElement($name);
foreach ($content as $sub_name => $sub_content) {
......@@ -276,14 +259,16 @@ class XmlSitemapWriter extends \XMLWriter {
throw new XmlSitemapGenerationException(t('Unknown error occurred while writing to file @file.', ['@file' => $this->uri]));
}
// @codingStandardsIgnoreStart
if (xmlsitemap_var('gz')) {
$file_gz = $this->uri . '.gz';
file_put_contents($file_gz, gzencode(file_get_contents($this->uri), 9));
}
// @codingStandardsIgnoreEnd
return $return;
}
protected function isIndex() {
return $this->page === 'index';
}
}
......@@ -19,7 +19,6 @@ use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
......@@ -298,7 +297,7 @@ function xmlsitemap_var($name, $default = NULL) {
* @param mixed $smid
* An XML sitemap ID.
*
* @return object
* @return \Drupal\xmlsitemap\XmlSitemapInterface
* The XML sitemap object.
*/
function xmlsitemap_sitemap_load($smid) {
......@@ -309,18 +308,15 @@ function xmlsitemap_sitemap_load($smid) {
/**
* Load multiple XML sitemaps from the database.
*
* @param array $smids
* @param array|bool $smids
* An array of XML sitemap IDs, or FALSE to load all XML sitemaps.
* @param array $conditions
* An array of conditions in the form 'field' => $value.
*
* @return array
* @return \Drupal\xmlsitemap\XmlSitemapInterface[]
* An array of XML sitemap objects.
*
* @codingStandardsIgnoreStart
*/
function xmlsitemap_sitemap_load_multiple($smids = [], array $conditions = []) {
// @codingStandardsIgnoreEnd
if ($smids !== FALSE) {
$conditions['smid'] = $smids;
}
......@@ -329,14 +325,11 @@ function xmlsitemap_sitemap_load_multiple($smids = [], array $conditions = []) {
}
$storage = Drupal::entityTypeManager()->getStorage('xmlsitemap');
/** @var \Drupal\xmlsitemap\XmlSitemapInterface[] $sitemaps */
$sitemaps = $storage->loadMultiple($conditions['smid']);
if (count($sitemaps) <= 0) {
return [];
}
foreach ($sitemaps as &$sitemap) {
$uri = xmlsitemap_sitemap_uri($sitemap);
$sitemap->uri = $uri;
}
return $sitemaps;
}
......@@ -395,7 +388,7 @@ function xmlsitemap_sitemap_delete_multiple(array $smids) {
if (!empty($smids)) {
$sitemaps = xmlsitemap_sitemap_load_multiple($smids);
foreach ($sitemaps as $sitemap) {
xmlsitemap_clear_directory($sitemap, TRUE);
//xmlsitemap_clear_directory($sitemap, TRUE);
$sitemap->delete();
\Drupal::moduleHandler()->invokeAll('xmlsitemap_sitemap_delete', [$sitemap]);
}
......@@ -1589,7 +1582,8 @@ function xmlsitemap_form_alter(array &$form, FormStateInterface $form_state, $fo
* Implements hook_xmlsitemap_index_links().
*/
function xmlsitemap_xmlsitemap_index_links($limit) {
$entity_types = \Drupal::entityTypeManager()->getDefinitions();
$entity_type_manager = \Drupal::entityTypeManager();
$entity_types = $entity_type_manager->getDefinitions();
$bundles = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo();
foreach ($entity_types as $entity_type_id => $entity_type) {
// Don't try to loop over non-content entity types or with no bundle
......@@ -1608,18 +1602,26 @@ function xmlsitemap_xmlsitemap_index_links($limit) {
if (empty($entity_bundles)) {
continue;
}
try {
$query = \Drupal::entityTypeManager()->getStorage($entity_type_id)->getQuery();
$query = $entity_type_manager->getStorage($entity_type_id)->getQuery();
$query->range(0, $limit);
if ($entity_type->hasKey('bundle')) {
$bundle_key = $entity_type->getKey('bundle');
$query->condition($bundle_key, $entity_bundles, 'IN');
}
$ids = $query->execute();
xmlsitemap_xmlsitemap_process_entity_links($entity_type_id, $ids);
}
catch (QueryException $e) {
// Chunk the array into batch sizes.
$chunks = array_chunk($ids, \Drupal::config('xmlsitemap.settings')->get('batch_limit'));
foreach ($chunks as $chunk) {
xmlsitemap_xmlsitemap_process_entity_links($entity_type_id, $chunk);
// Reset the entity cache afte
$entity_type_manager->getStorage($entity_type_id)->resetCache();
}
}
catch (\Exception $e) {
watchdog_exception('xmlsitemap', $e);
}
}
}
......@@ -1638,7 +1640,6 @@ function xmlsitemap_xmlsitemap_process_entity_links($entity_type_id, array $enti
foreach ($entities as $entity) {
xmlsitemap_xmlsitemap_process_entity_link($entity);
}
\Drupal::entityTypeManager()->getStorage($entity_type_id)->resetCache();
}
......
services:
xmlsitemap_generator:
class: Drupal\xmlsitemap\XmlSitemapGenerator
arguments: ['@config.factory', '@state', '@language_manager', '@logger.channel.xmlsitemap', '@module_handler']
arguments: [
'@config.factory',
'@state',
'@language_manager',
'@logger.channel.xmlsitemap',
'@module_handler',
'@entity_type.manager',