Commit e963e288 authored by gbyte.co's avatar gbyte.co Committed by gbyte.co

Issue #2924080 by gbyte.co: Use queue API for cron generation instead of batch API

parent fb255e3b
max_links: 2000
cron_generate: true
cron_generate_interval: 0
generate_duration: 10000
remove_duplicates: true
skip_untranslated: true
batch_process_limit: 1500
base_url: ''
default_variant: 'default'
custom_links_include_images: false
......
......@@ -5,10 +5,13 @@ simple_sitemap.settings:
label: 'Max links'
type: integer
cron_generate:
label: 'Cron generate'
label: 'Cron generation'
type: boolean
cron_generate_interval:
label: 'Cron generate interval'
label: 'Cron generation interval'
type: integer
generate_duration:
label: 'Generation duration'
type: integer
remove_duplicates:
label: 'Remove duplicates'
......@@ -16,9 +19,6 @@ simple_sitemap.settings:
skip_untranslated:
label: 'Skip untranslated'
type: boolean
batch_process_limit:
label: 'Batch process limit'
type: integer
base_url:
label: 'Base URL'
type: string
......@@ -89,3 +89,6 @@ simple_sitemap.variants.*:
label:
label: 'Variant label'
type: string
weight:
label: 'Weight'
type: integer
......@@ -14,6 +14,13 @@ function simple_sitemap_drush_command() {
'callback' => 'drush_simple_sitemap_generate',
'drupal dependencies' => ['simple_sitemap'],
];
$items['simple_sitemap-rebuild-queue'] = [
'description' => 'Rebuild the sitemap queue for all sitemap variants.',
'callback' => 'drush_simple_sitemap_rebuild_queue',
'drupal dependencies' => ['simple_sitemap'],
];
return $items;
}
......@@ -25,3 +32,12 @@ function simple_sitemap_drush_command() {
function drush_simple_sitemap_generate() {
\Drupal::service('simple_sitemap.generator')->generateSitemap('drush');
}
/**
* Callback function for hook_drush_command().
*
* Rebuild the sitemap queue for all sitemap variants.
*/
function drush_simple_sitemap_rebuild_queue() {
\Drupal::service('simple_sitemap.generator')->rebuildQueue();
}
......@@ -5,8 +5,6 @@
* Module install and update procedures.
*/
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorBase;
/**
* Implements hook_requirements().
*
......@@ -30,7 +28,7 @@ function simple_sitemap_requirements($phase) {
case 'runtime':
$generator = \Drupal::service('simple_sitemap.generator');
$generated_ago = $generator->getGeneratedAgo(\Drupal\simple_sitemap\Simplesitemap::DEFAULT_SITEMAP_VARIANT); //todo
$generated_ago = $generator->getGeneratedAgo(\Drupal\simple_sitemap\SimplesitemapManager::DEFAULT_SITEMAP_VARIANT); //todo
$cron_generation = $generator->getSetting('cron_generate');
if (!$generated_ago) {
......@@ -104,9 +102,17 @@ function simple_sitemap_schema() {
'sitemap_created' => [
'description' => 'Timestamp of sitemap chunk generation.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
],
'status' => [
'description' => "Flag indicating the publishing status of the chunk.",
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
],
],
'primary key' => ['id'],
......@@ -118,8 +124,8 @@ function simple_sitemap_schema() {
'id' => [
'description' => 'Override unique identifier.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'unsigned' => TRUE,
],
'entity_type' => [
'description' => 'Entity type of the overriding entity.',
......@@ -562,3 +568,39 @@ function simple_sitemap_update_8214() {
$config_factory->getEditable($type)->delete();
}
}
/**
* Adding 'status' field to simple_sitemap table and weight to variants.
*/
function simple_sitemap_update_8215() {
$database = \Drupal::database();
$database->truncate('simple_sitemap')->execute();
if (!$database->schema()->fieldExists('simple_sitemap', 'status')) {
$database->schema()->addField(
'simple_sitemap',
'status', [
'description' => "Flag indicating the publishing status of the chunk.",
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
]
);
}
$config_factory = \Drupal::service('config.factory');
foreach ($config_factory->listAll('simple_sitemap.variants.') as $type) {
/** @var \Drupal\Core\Config\Config $type */
$type = $config_factory->getEditable($type);
$variants = $type->get('variants');
foreach($variants as $i => $variant) {
$variants[$i]['weight'] = 0;
}
$type->set('variants', $variants)->save();
}
return t('The XML sitemaps need to be regenerated.');
}
......@@ -148,7 +148,7 @@ function simple_sitemap_cron() {
$requestTime = \Drupal::service('datetime.time')->getRequestTime();
if ($interval === 0 || ((\Drupal::state()->get('simple_sitemap.last_cron_generate', 0) + $interval) <= $requestTime)) {
\Drupal::state()->set('simple_sitemap.last_cron_generate', $requestTime);
$generator->generateSitemap('backend');
$generator->generateSitemap('cron');
}
}
}
......
......@@ -4,6 +4,8 @@ services:
public: true
arguments:
- '@simple_sitemap.entity_helper'
- '@simple_sitemap.settings'
- '@simple_sitemap.manager'
- '@config.factory'
- '@database'
- '@entity_type.manager'
......@@ -12,10 +14,40 @@ services:
- '@date.formatter'
- '@datetime.time'
- '@module_handler'
- '@simple_sitemap.batch'
- '@simple_sitemap.queue_worker'
simple_sitemap.manager:
class: Drupal\simple_sitemap\SimplesitemapManager
public: true
arguments:
- '@config.factory'
- '@plugin.manager.simple_sitemap.sitemap_type'
- '@plugin.manager.simple_sitemap.url_generator'
- '@plugin.manager.simple_sitemap.sitemap_generator'
- '@plugin.manager.simple_sitemap.sitemap_type'
simple_sitemap.settings:
class: Drupal\simple_sitemap\SimplesitemapSettings
public: true
arguments:
- '@config.factory'
simple_sitemap.queue_worker:
class: Drupal\simple_sitemap\Queue\QueueWorker
public: true
arguments:
- '@simple_sitemap.settings'
- '@simple_sitemap.manager'
- '@state'
- '@module_handler'
- '@simple_sitemap.element_queue'
- '@lock'
simple_sitemap.element_queue:
class: Drupal\simple_sitemap\Queue\ElementQueue
public: false
arguments:
- 'simple_sitemap_elements'
- '@database'
simple_sitemap.sitemap_writer:
class: Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapWriter
......@@ -36,10 +68,6 @@ services:
- '@simple_sitemap.entity_helper'
- '@current_user'
simple_sitemap.batch:
class: Drupal\simple_sitemap\Batch
public: false
simple_sitemap.logger:
class: Drupal\simple_sitemap\Logger
public: true
......
<?php
namespace Drupal\simple_sitemap;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorBase;
use Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\UrlGeneratorBase;
/**
* Class Batch
* @package Drupal\simple_sitemap\Batch
*
* The services of this class are not injected, as this class looses its state
* on every method call because of how the batch API works.
*/
class Batch {
use StringTranslationTrait;
/**
* @var array
*/
protected $batch;
/**
* @var array
*/
protected $batchMeta;
const BATCH_TITLE = 'Generating XML sitemap';
const BATCH_INIT_MESSAGE = 'Initializing batch...';
const BATCH_ERROR_MESSAGE = 'An error has occurred. This may result in an incomplete XML sitemap.';
const BATCH_PROGRESS_MESSAGE = 'Running @current out of @total operations.';
const REGENERATION_FINISHED_MESSAGE = 'The XML sitemaps have been regenerated.';
const REGENERATION_FINISHED_ERROR_MESSAGE = 'The sitemap generation finished with an error.';
/**
* Batch constructor.
*/
public function __construct() {
$this->batch = [
'title' => $this->t(self::BATCH_TITLE),
'init_message' => $this->t(self::BATCH_INIT_MESSAGE),
'error_message' => $this->t(self::BATCH_ERROR_MESSAGE),
'progress_message' => $this->t(self::BATCH_PROGRESS_MESSAGE),
'operations' => [],
'finished' => [__CLASS__, 'finishGeneration'],
];
}
/**
* @param array $batch_meta
*/
public function setBatchMeta(array $batch_meta) {
$this->batchMeta = $batch_meta;
}
/**
* Adds an operation to the batch.
*
* @param string $operation_name
* @param array $arguments
*/
public function addOperation($operation_name, $arguments = []) {
$this->batch['operations'][] = [
__CLASS__ . '::' . $operation_name, [$arguments, $this->batchMeta]
];
}
/**
* Batch callback function which generates URLs.
*
* @param array $arguments
* @param array $batch_meta
* @param $context
*
* @see https://api.drupal.org/api/drupal/core!includes!form.inc/group/batch/8
*/
public static function generateSitemap(array $arguments, array $batch_meta, &$context) {
/** @var UrlGeneratorBase $url_generator*/
$url_generator = \Drupal::service('plugin.manager.simple_sitemap.url_generator')
->createInstance($arguments['url_generator']);
$url_generator
->setContext($context)
->setSettings($arguments['settings'])
->setBatchMeta($batch_meta)
->setSitemapVariant($arguments['variant'])
->setSitemapGeneratorId($arguments['sitemap_generator'])
->generate($arguments['data_set']);
}
/**
* Batch callback function which generates URLs.
*
* @param array $arguments
* @param array $batch_meta
* @param $context
*
* @see https://api.drupal.org/api/drupal/core!includes!form.inc/group/batch/8
*/
public static function generateIndex(array $arguments, array $batch_meta, &$context) {
/** @var SitemapGeneratorBase $sitemap_generator*/
$sitemap_generator = \Drupal::service('plugin.manager.simple_sitemap.sitemap_generator')
->createInstance($arguments['sitemap_generator']);
$sitemap_generator
->setSettings($arguments['settings'])
->setSitemapVariant($arguments['variant'])
->generateIndex();
}
/**
* Batch callback function which generates URLs.
*
* @param array $arguments
* @param array $batch_meta
* @param $context
*
* @see https://api.drupal.org/api/drupal/core!includes!form.inc/group/batch/8
*/
public static function removeSitemap(array $arguments, array $batch_meta, &$context) {
/** @var SitemapGeneratorBase $sitemap_generator*/
$sitemap_generator = \Drupal::service('plugin.manager.simple_sitemap.sitemap_generator')
->createInstance($arguments['sitemap_generator']);
$sitemap_generator
->setSitemapVariant($arguments['variant'])
->remove()
->invalidateCache();
}
/**
* Callback function called by the batch API when all operations are finished.
*
* @param $success
* @param $results
* @param $operations
*
* @return bool
*
* @see https://api.drupal.org/api/drupal/core!includes!form.inc/group/batch/8
*
* @todo Display success/failure message in Drush > 9.
*/
public static function finishGeneration($success, $results, $operations) {
if ($success) {
\Drupal::service('simple_sitemap.logger')
->m(self::REGENERATION_FINISHED_MESSAGE)
// ['@url' => $this->sitemapGenerator->getCustomBaseUrl() . '/sitemap.xml']) //todo: Use actual base URL for message.
->display('status')
->log('info');
}
else {
\Drupal::service('simple_sitemap.logger')
->m(self::REGENERATION_FINISHED_ERROR_MESSAGE)
->display('error', 'administer sitemap settings')
->log('error');
}
return $success;
}
/**
* Starts the batch process depending on where it was requested from.
*
* @return bool
*/
public function start() {
// Update last operation info for each operation.
$this->addAdditionalMetaInfo();
switch ($this->batchMeta['from']) {
case 'form':
// Start batch process.
batch_set($this->batch);
return TRUE;
case 'drush':
// Start drush batch process.
batch_set($this->batch);
// See https://www.drupal.org/node/638712
$this->batch =& batch_get();
$this->batch['progressive'] = FALSE;
drush_log($this->t(self::BATCH_INIT_MESSAGE), 'status');
drush_backend_batch_process();
return TRUE;
case 'backend':
// Start backend batch process.
batch_set($this->batch);
// See https://www.drupal.org/node/638712
$this->batch =& batch_get();
$this->batch['progressive'] = FALSE;
// todo: Does not take advantage of batch API and eventually runs out of memory on very large sites. Use queue API instead?
batch_process();
return TRUE;
case 'nobatch':
// Call each batch operation the way the Drupal batch API would do, but
// within one process (so in fact not using batch API here, just
// mimicking it to avoid code duplication).
$context = [];
foreach ($this->batch['operations'] as $i => $operation) {
$operation[1][] = &$context;
call_user_func_array($operation[0], $operation[1]);
}
return $this->finishGeneration(TRUE, !empty($context['results']) ? $context['results'] : [], []);
}
return FALSE;
}
protected function addAdditionalMetaInfo() {
$last_operation_no = 0;
foreach ($this->batch['operations'] as $i => $operation) {
if ($operation[0] === __CLASS__ . '::generateSitemap') {
$this->batch['operations'][$i][1][1]['current_generate_sitemap_operation_no'] = $i;
$last_operation_no = $i;
}
}
foreach ($this->batch['operations'] as $i => $operation) {
if ($operation[0] === __CLASS__ . '::generateSitemap') {
$this->batch['operations'][$i][1][1]['last_generate_sitemap_operation_no'] = $last_operation_no;
}
}
}
}
......@@ -35,4 +35,15 @@ class SimplesitemapCommands extends DrushCommands {
$this->generator->generateSitemap('drush');
}
/**
* Rebuild the sitemap queue for all sitemap variants.
*
* @command simple-sitemap:rebuild-queue
* @validate-module-enabled simple_sitemap
* @aliases ss:rebuild-queue, ssr, simple_sitemap:rebuild-queue, simple_sitemap-rebuild-queue
*/
public function rebuildQueue() {
$this->generator->rebuildQueue();
}
}
......@@ -55,7 +55,7 @@ class SimplesitemapController extends ControllerBase {
* @param string $variant
* Optional name of sitemap variant.
* @see \hook_simple_sitemap_variants_alter()
* @see Simplesitemap::getSitemapVariants()
* @see SimplesitemapManager::getSitemapVariants()
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
namespace Drupal\simple_sitemap\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\simple_sitemap\Simplesitemap;
use Drupal\simple_sitemap\SimplesitemapManager;
/**
* Class SimplesitemapVariantsForm
......@@ -33,11 +33,11 @@ class SimplesitemapVariantsForm extends SimplesitemapFormBase {
$form['simple_sitemap_variants']['variants'] = [
'#type' => 'textarea',
'#title' => $this->t('Variants'),
'#default_value' => $this->variantsToString($this->generator->getSitemapVariants(NULL, TRUE)),
'#description' => $this->t("Please specify sitemap variants, one per line.<br/>A variant definition consists of the variant name (used as the variant's path), the sitemap type it belongs to (optional) and the variant label (optional).<br/>These three values have to be separated by the | pipe | symbol.<br/><br/><strong>Examples:</strong><br/><em>default | default_hreflang | Default</em> -> variant of the <em>default_hreflang</em> sitemap type and <em>Default</em> as label; accessible under <em>/default/sitemap.xml</em><br/><em>test</em> -> variant of the <em>@default_sitemap_type</em> sitemap type and <em>test</em> as label; accessible under <em>/test/sitemap.xml</em><br/><br/><strong>Available sitemap types:</strong>", ['@default_sitemap_type' => Simplesitemap::DEFAULT_SITEMAP_TYPE]),
'#default_value' => $this->variantsToString($this->generator->getSitemapManager()->getSitemapVariants(NULL, TRUE)),
'#description' => $this->t("Please specify sitemap variants, one per line.<br/>A variant definition consists of the variant name (used as the variant's path), the sitemap type it belongs to (optional) and the variant label (optional).<br/>These three values have to be separated by the | pipe | symbol.<br/><br/><strong>Examples:</strong><br/><em>default | default_hreflang | Default</em> -> variant of the <em>default_hreflang</em> sitemap type and <em>Default</em> as label; accessible under <em>/default/sitemap.xml</em><br/><em>test</em> -> variant of the <em>@default_sitemap_type</em> sitemap type and <em>test</em> as label; accessible under <em>/test/sitemap.xml</em><br/><br/><strong>Available sitemap types:</strong>", ['@default_sitemap_type' => SimplesitemapManager::DEFAULT_SITEMAP_TYPE]),
];
foreach ($this->generator->getSitemapTypes() as $sitemap_type => $definition) {
foreach ($this->generator->getSitemapManager()->getSitemapTypes() as $sitemap_type => $definition) {
$form['simple_sitemap_variants']['variants']['#description'] .= '<br/>' . '<em>' . $sitemap_type . '</em>' . (!empty($definition['description']) ? (': ' . $definition['description']) : '');
}
......@@ -53,7 +53,7 @@ class SimplesitemapVariantsForm extends SimplesitemapFormBase {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$line = 0;
$sitemap_types = $this->generator->getSitemapTypes();
$sitemap_types = $this->generator->getSitemapManager()->getSitemapTypes();
foreach ($this->stringToVariants($form_state->getValue('variants')) as $variant_name => $variant_definition) {
$placeholders = [
'@line' => ++$line,
......@@ -80,9 +80,11 @@ class SimplesitemapVariantsForm extends SimplesitemapFormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->generator->removeSitemapVariants();
$this->generator->getSitemapManager()->removeSitemapVariants();
$weight = 0;
foreach ($this->stringToVariants($form_state->getValue('variants')) as $variant_name => $variant_definition) {
$this->generator->addSitemapVariant($variant_name, $variant_definition);
$this->generator->getSitemapManager()->addSitemapVariant($variant_name, $variant_definition + ['weight' => $weight]);
$weight++;
}
parent::submitForm($form, $form_state);
......@@ -108,7 +110,7 @@ class SimplesitemapVariantsForm extends SimplesitemapFormBase {
foreach ($variants_string_lines as $i => &$line) {
$variant_settings = explode('|', $line);
$name = strtolower(trim($variant_settings[0]));
$variants[$name]['type'] = !empty($variant_settings[1]) ? trim($variant_settings[1]) : Simplesitemap::DEFAULT_SITEMAP_TYPE;
$variants[$name]['type'] = !empty($variant_settings[1]) ? trim($variant_settings[1]) : SimplesitemapManager::DEFAULT_SITEMAP_TYPE;
$variants[$name]['label'] = !empty($variant_settings[2]) ? trim($variant_settings[2]) : $name;
}
return $variants;
......
......@@ -139,6 +139,7 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
->fields('s', ['delta', 'sitemap_created', 'type'])
->condition('s.type', $this->sitemapVariant)
->condition('s.delta', self::INDEX_DELTA, '<>')
->condition('s.status', 0)
->execute()
->fetchAllAssoc('delta');
}
......@@ -182,10 +183,23 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
/**
* @return $this
*/
public function remove() {
$this->db->delete('simple_sitemap')
->condition('type', $this->sitemapVariant)
->execute();
public function remove($mode = 'all') {
$query = $this->db->delete('simple_sitemap')
->condition('type', $this->sitemapVariant);
switch($mode) {
case 'published':
$query->condition('status', 1);
break;
case 'unpublished':
$query->condition('status', 0);
break;
case 'all':
break;
default:
//todo: throw error
}
$query->execute();
return $this;
}
......@@ -201,18 +215,17 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
*/
public function generate(array $links) {
$highest_id = $this->db->query('SELECT MAX(id) FROM {simple_sitemap}')->fetchField();
$highest_delta = $this->db->query('SELECT MAX(delta) FROM {simple_sitemap} WHERE type = :type', [':type' => $this->sitemapVariant])
$highest_delta = $this->db->query('SELECT MAX(delta) FROM {simple_sitemap} WHERE type = :type AND status = :status', [':type' => $this->sitemapVariant, ':status' => 0])
->fetchField();
$values = [
$this->db->insert('simple_sitemap')->fields([
'id' => NULL === $highest_id ? 0 : $highest_id + 1,
'delta' => NULL === $highest_delta ? self::FIRST_CHUNK_DELTA : $highest_delta + 1,
'type' => $this->sitemapVariant,
'sitemap_string' => $this->getXml($links),
'sitemap_created' => $this->time->getRequestTime(),
];
$this->db->insert('simple_sitemap')->fields($values)->execute();
'status' => 0,
])->execute();
return $this;
}
......@@ -226,16 +239,20 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
$index_xml = $this->getIndexXml($chunk_info);
$highest_id = $this->db->query('SELECT MAX(id) FROM {simple_sitemap}')->fetchField();
$this->db->merge('simple_sitemap')
->key(['delta' => self::INDEX_DELTA, 'type' => $this->sitemapVariant])
->keys([
'delta' => self::INDEX_DELTA,
'type' => $this->sitemapVariant,
'status' => 0
])
->insertFields([
'id' => NULL === $highest_id ? 0 : $highest_id + 1,
'delta' => self::INDEX_DELTA,
'type' => $this->sitemapVariant,
'sitemap_string' => $index_xml,
'sitemap_created' => $this->time->getRequestTime(),
'status' => 0,
])
->updateFields([
'type' => $this->sitemapVariant,
'sitemap_string' => $index_xml,
'sitemap_created' => $this->time->getRequestTime(),
])
......@@ -245,6 +262,21 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
return $this;
}
public function publish() {
$unpublished_chunk = $this->db->query('SELECT MAX(id) FROM {simple_sitemap} WHERE type = :type AND status = :status', [':type' => $this->sitemapVariant, ':status' => 0])
->fetchField();
// Only allow publishing a sitemap variant if there is an unpublished
// sitemap variant, as publishing involves deleting the currently published
// variant.
if (FALSE !== $unpublished_chunk) {
$this->remove('published');
$this->db->query('UPDATE {simple_sitemap} SET status = :status WHERE type = :type', [':type' => $this->sitemapVariant, ':status' => 1]);
}
return $this;
}
/**
* @return $this
* @todo: Variant cannot be null
......
......@@ -5,7 +5,6 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator;
use Drupal\simple_sitemap\EntityHelper;
use Drupal\simple_sitemap\Logger;
use Drupal\simple_sitemap\Simplesitemap;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorManager;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandler;
......@@ -28,22 +27,22 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase {
/**
* ArbitraryUrlGenerator constructor.
* @param array $configuration
* @param string $plugin_id
* @param mixed $plugin_definition
* @param $plugin_id
* @param $plugin_definition
* @param \Drupal\simple_sitemap\Simplesitemap $generator
* @param \Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorManager $sitemap_generator_manager
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\simple_sitemap\Logger $logger
* @param \Drupal\simple_sitemap\EntityHelper $entityHelper
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
Simplesitemap $generator,
SitemapGeneratorManager $sitemap_generator_manager,
LanguageManagerInterface $language_manager,
EntityTypeManagerInterface $entity_type_manager,
Logger $logger,
......@@ -55,7 +54,6 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase {
$plugin_id,
$plugin_definition,
$generator,
$sitemap_generator_manager,
$language_manager,
$entity_type_manager,
$logger,
......@@ -74,7 +72,6 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase {
$plugin_id,
$plugin_definition,
$container->get('simple_sitemap.generator'),
$container->get('plugin.manager.simple_sitemap.sitemap_generator'),
$container->get('language_manager'),
$container->get('entity_type.manager'),
$container->get('simple_sitemap.logger'),
......@@ -83,17 +80,14 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase {
);
}
/**
* @inheritdoc
*/
public function getDataSets() {
$data_sets = [];
$arbitrary_links = [];
$sitemap_variant = $this->sitemapVariant;
$this->moduleHandler->alter('simple_sitemap_arbitrary_links', $arbitrary_links, $sitemap_variant);
$data_sets[] = array_values($arbitrary_links);
return $data_sets;
return array_values($arbitrary_links);
}
/**
......
......@@ -7,7 +7,6 @@ use Drupal\simple_sitemap\Annotation\UrlGenerator;
use Drupal\simple_sitemap\EntityHelper;
use Drupal\simple_sitemap\Logger;
use Drupal\simple_sitemap\Simplesitemap;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorManager;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Path\PathValidator;
......@@ -42,22 +41,22 @@ class CustomUrlGenerator extends UrlGeneratorBase {
/**
* CustomUrlGenerator constructor.