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

Fix plugin interfaces

parent 9b81940e
......@@ -39,11 +39,11 @@ services:
- '@simple_sitemap.manager'
- '@state'
- '@module_handler'
- '@simple_sitemap.element_queue'
- '@simple_sitemap.queue'
- '@lock'
simple_sitemap.element_queue:
class: Drupal\simple_sitemap\Queue\ElementQueue
simple_sitemap.queue:
class: Drupal\simple_sitemap\Queue\SimplesitemapQueue
public: false
arguments:
- 'simple_sitemap_elements'
......
......@@ -8,10 +8,17 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator;
*/
interface SitemapGeneratorInterface {
public function generate(array $links);
function setSitemapVariant($sitemap_variant);
public function generateIndex();
function setSettings(array $settings);
public function remove();
function generate(array $links);
function generateIndex();
function publish();
function remove();
function invalidateCache();
}
......@@ -8,7 +8,11 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator;
*/
interface UrlGeneratorInterface {
public function generate($data_sets);
function setSettings(array $settings);
public function getDataSets();
function setSitemapVariant($sitemap_variant);
function getDataSets();
function generate($data_set);
}
......@@ -42,9 +42,9 @@ class QueueWorker {
protected $lock;
/**
* @var array|\Drupal\simple_sitemap\Queue\ElementQueue
* @var \Drupal\simple_sitemap\Queue\SimplesitemapQueue
*/
protected $elementQueue = [];
protected $queue;
/**
* @var string|null
......@@ -87,20 +87,20 @@ class QueueWorker {
* @param \Drupal\simple_sitemap\SimplesitemapManager $manager
* @param \Drupal\Core\State\State $state
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @param \Drupal\simple_sitemap\Queue\ElementQueue $element_queue
* @param \Drupal\simple_sitemap\Queue\SimplesitemapQueue $element_queue
* @param \Drupal\Core\Lock\LockBackendInterface $lock
*/
public function __construct(SimplesitemapSettings $settings,
SimplesitemapManager $manager,
State $state,
ModuleHandler $module_handler,
ElementQueue $element_queue,
SimplesitemapQueue $element_queue,
LockBackendInterface $lock) {
$this->settings = $settings;
$this->manager = $manager;
$this->state = $state;
$this->moduleHandler = $module_handler;
$this->elementQueue = $element_queue;
$this->queue = $element_queue;
$this->lock = $lock;
}
......@@ -110,7 +110,7 @@ class QueueWorker {
* @todo Should remove all unpublished variants from db.
*/
public function deleteQueue() {
$this->elementQueue->deleteQueue();
$this->queue->deleteQueue();
$this->variantProcessedNow = NULL;
$this->generatorProcessedNow = NULL;
$this->results = [];
......@@ -122,8 +122,8 @@ class QueueWorker {
return $this;
}
public function getElementQueue() {
return $this->elementQueue;
public function getQueue() {
return $this->queue;
}
/**
......@@ -184,7 +184,7 @@ class QueueWorker {
}
protected function queueElements($elements) {
$this->elementQueue->createItems($elements);
$this->queue->createItems($elements);
$this->state->set('simple_sitemap.queue_items_initial_amount', ($this->state->get('simple_sitemap.queue_items_initial_amount') + count($elements)));
}
......@@ -216,7 +216,7 @@ class QueueWorker {
$this->rebuildQueue($variants);
}
while ($element = $this->elementQueue->claimItem()) {
while ($element = $this->queue->claimItem()) {
if (!empty($max_execution_time) && Timer::read('simple_sitemap_generator') >= $max_execution_time) {
break;
......@@ -244,7 +244,7 @@ class QueueWorker {
watchdog_exception('simple_sitemap', $e);
}
$this->elementQueue->deleteItem($element); //todo May want to use deleteItems() instead.
$this->queue->deleteItem($element); //todo May want to use deleteItems() instead.
$elements_processed++;
$this->elementsRemaining--;
}
......@@ -333,7 +333,7 @@ class QueueWorker {
public function getRemainingElementCount($force_recount = FALSE) {
if ($force_recount || NULL === $this->elementsRemaining) {
$this->elementsRemaining = $this->elementQueue->numberOfItems();
$this->elementsRemaining = $this->queue->numberOfItems();
}
return $this->elementsRemaining;
......
......@@ -5,12 +5,10 @@ namespace Drupal\simple_sitemap\Queue;
use Drupal\Core\Queue\DatabaseQueue;
/**
* Class ElementQueue
* Class SimplesitemapQueue
* @package Drupal\simple_sitemap\Queue
*
* @todo Need to override claimItem() to what Batch queue uses.
*/
class ElementQueue extends DatabaseQueue {
class SimplesitemapQueue extends DatabaseQueue {
/**
* Overrides \Drupal\Core\Queue\DatabaseQueue::claimItem().
......
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