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

Remove sitemaps from DB when removing variants from configuration

parent 67de3e4b
......@@ -183,12 +183,13 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
* @return $this
*/
public function remove($mode = 'all') {
self::removeSitemapVariant($this->sitemapVariant, $mode);
self::removeSitemapVariants($this->sitemapVariant, $mode);
return $this;
}
public static function removeSitemapVariant($variant = NULL, $mode = 'all') {
public static function removeSitemapVariants($variants = NULL, $mode = 'all') {
$variants = is_array($variants) || NULL === $variants ? $variants : [$variants];
$delete_query = \Drupal::database()->delete('simple_sitemap');
switch($mode) {
......@@ -207,8 +208,8 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
//todo: throw error
}
if (NULL !== $variant) {
$delete_query->condition('type', $variant);
if (NULL !== $variants) {
$delete_query->condition('type', $variants, 'IN');
}
$delete_query->execute();
......
......@@ -110,7 +110,7 @@ class QueueWorker {
*/
public function deleteQueue() {
$this->queue->deleteQueue();
SitemapGeneratorBase::removeSitemapVariant(NULL, 'unpublished');
SitemapGeneratorBase::removeSitemapVariants(NULL, 'unpublished'); //todo should call the remove() method of every plugin instead?
$this->variantProcessedNow = NULL;
$this->generatorProcessedNow = NULL;
$this->results = [];
......
......@@ -190,7 +190,8 @@ class SimplesitemapManager {
}
public function removeSitemapVariants($variant_names = NULL) {
// $this->removeSitemap($variant_names); // todo
SitemapGeneratorBase::removeSitemapVariants($variant_names); //todo should call the remove() method of every plugin instead?
if (NULL === $variant_names) {
foreach ($this->configFactory->listAll('simple_sitemap.variants.') as $config_name) {
$this->configFactory->getEditable($config_name)->delete();
......
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