Commit 6d0ba743 authored by gbyte.co's avatar gbyte.co

Allow adding arbitrary links without meta information, clean up

Arbitrarily added links without ['meta']['path'] info would cause errors on duplicate checking. This is fixed now.
parent 12ab9851
......@@ -13,7 +13,6 @@ services:
- '@path.validator'
- '@date.formatter'
- '@datetime.time'
- '@module_handler'
- '@simple_sitemap.queue_worker'
simple_sitemap.manager:
......@@ -40,7 +39,6 @@ services:
- '@simple_sitemap.settings'
- '@simple_sitemap.manager'
- '@state'
- '@module_handler'
- '@simple_sitemap.queue'
simple_sitemap.queue:
......
......@@ -2,7 +2,6 @@
namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\simple_sitemap\EntityHelper;
use Drupal\simple_sitemap\Logger;
use Drupal\simple_sitemap\Simplesitemap;
......@@ -35,11 +34,6 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
*/
protected $menuLinkTree;
/**
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* EntityMenuLinkContentUrlGenerator constructor.
* @param array $configuration
......@@ -51,9 +45,6 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
* @param \Drupal\simple_sitemap\Logger $logger
* @param \Drupal\simple_sitemap\EntityHelper $entityHelper
* @param \Drupal\Core\Menu\MenuLinkTree $menu_link_tree
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function __construct(
array $configuration,
......@@ -64,8 +55,7 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
EntityTypeManagerInterface $entity_type_manager,
Logger $logger,
EntityHelper $entityHelper,
MenuLinkTree $menu_link_tree,
ModuleHandler $module_handler
MenuLinkTree $menu_link_tree
) {
parent::__construct(
$configuration,
......@@ -78,7 +68,6 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
$entityHelper
);
$this->menuLinkTree = $menu_link_tree;
$this->moduleHandler = $module_handler;
}
public static function create(
......@@ -95,8 +84,7 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
$container->get('entity_type.manager'),
$container->get('simple_sitemap.logger'),
$container->get('simple_sitemap.entity_helper'),
$container->get('menu.link_tree'),
$container->get('module_handler')
$container->get('menu.link_tree')
);
}
......
......@@ -8,7 +8,6 @@ use Drupal\simple_sitemap\Simplesitemap;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Extension\ModuleHandler;
/**
* Class EntityUrlGenerator
......@@ -27,11 +26,6 @@ class EntityUrlGenerator extends UrlGeneratorBase {
*/
protected $urlGeneratorManager;
/**
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* EntityUrlGenerator constructor.
* @param array $configuration
......@@ -43,9 +37,6 @@ class EntityUrlGenerator extends UrlGeneratorBase {
* @param \Drupal\simple_sitemap\Logger $logger
* @param \Drupal\simple_sitemap\EntityHelper $entityHelper
* @param \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\UrlGeneratorManager $url_generator_manager
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function __construct(
array $configuration,
......@@ -56,8 +47,7 @@ class EntityUrlGenerator extends UrlGeneratorBase {
EntityTypeManagerInterface $entity_type_manager,
Logger $logger,
EntityHelper $entityHelper,
UrlGeneratorManager $url_generator_manager,
ModuleHandler $module_handler
UrlGeneratorManager $url_generator_manager
) {
parent::__construct(
$configuration,
......@@ -70,7 +60,6 @@ class EntityUrlGenerator extends UrlGeneratorBase {
$entityHelper
);
$this->urlGeneratorManager = $url_generator_manager;
$this->moduleHandler = $module_handler;
}
public static function create(
......@@ -87,8 +76,7 @@ class EntityUrlGenerator extends UrlGeneratorBase {
$container->get('entity_type.manager'),
$container->get('simple_sitemap.logger'),
$container->get('simple_sitemap.entity_helper'),
$container->get('plugin.manager.simple_sitemap.url_generator'),
$container->get('module_handler')
$container->get('plugin.manager.simple_sitemap.url_generator')
);
}
......
......@@ -5,7 +5,6 @@ namespace Drupal\simple_sitemap\Queue;
use Drupal\Component\Utility\Timer;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorBase;
use Drupal\simple_sitemap\SimplesitemapSettings;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\simple_sitemap\SimplesitemapManager;
use Drupal\Core\State\State;
......@@ -31,11 +30,6 @@ class QueueWorker {
*/
protected $state;
/**
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* @var \Drupal\simple_sitemap\Queue\SimplesitemapQueue
*/
......@@ -86,18 +80,15 @@ class QueueWorker {
* @param \Drupal\simple_sitemap\SimplesitemapSettings $settings
* @param \Drupal\simple_sitemap\SimplesitemapManager $manager
* @param \Drupal\Core\State\State $state
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @param \Drupal\simple_sitemap\Queue\SimplesitemapQueue $element_queue
*/
public function __construct(SimplesitemapSettings $settings,
SimplesitemapManager $manager,
State $state,
ModuleHandler $module_handler,
SimplesitemapQueue $element_queue) {
$this->settings = $settings;
$this->manager = $manager;
$this->state = $state;
$this->moduleHandler = $module_handler;
$this->queue = $element_queue;
}
......@@ -270,14 +261,15 @@ class QueueWorker {
* @param array $results
*/
protected function removeDuplicates(&$results) {
if ($this->generatorSettings['remove_duplicates']
&& !empty($results)
&& !empty($path = $results[key($results)]['meta']['path'])) {
if (in_array($path, $this->processedPaths)) {
$results = [];
}
else {
$this->processedPaths[] = $path;
if ($this->generatorSettings['remove_duplicates'] && !empty($results)) {
$result = $results[key($results)];
if (!empty($result['meta']['path'])) {
if (in_array($result['meta']['path'], $this->processedPaths)) {
$results = [];
}
else {
$this->processedPaths[] = $result['meta']['path'];
}
}
}
}
......
......@@ -5,13 +5,11 @@ namespace Drupal\simple_sitemap;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\simple_sitemap\Queue\QueueWorker;
use Drupal\Core\Path\PathValidator;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Component\Datetime\Time;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\DefaultSitemapGenerator;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorBase;
/**
......@@ -69,11 +67,6 @@ class Simplesitemap {
*/
protected $time;
/**
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* @var \Drupal\simple_sitemap\Queue\QueueWorker
*/
......@@ -114,7 +107,6 @@ class Simplesitemap {
* @param \Drupal\Core\Path\PathValidator $path_validator
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Component\Datetime\Time $time
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @param \Drupal\simple_sitemap\Queue\QueueWorker $queue_worker
*/
public function __construct(
......@@ -128,7 +120,6 @@ class Simplesitemap {
PathValidator $path_validator,
DateFormatter $date_formatter,
Time $time,
ModuleHandler $module_handler,
QueueWorker $queue_worker
) {
$this->entityHelper = $entity_helper;
......@@ -141,7 +132,6 @@ class Simplesitemap {
$this->pathValidator = $path_validator;
$this->dateFormatter = $date_formatter;
$this->time = $time;
$this->moduleHandler = $module_handler;
$this->queueWorker = $queue_worker;
}
......
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