Commit 78fa4dd7 authored by gbyte.co's avatar gbyte.co

Clean up and add code documentation

parent 9f0d6b44
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
## INTRODUCTION ## ## INTRODUCTION ##
Author and maintainer: Pawel Ginalski (gbyte.co) Author and maintainer: Pawel Ginalski (gbyte.co)
https://www.drupal.org/u/gbyte.co * Drupal: https://www.drupal.org/u/gbyte.co
* Personal: https://gbyte.co/
The module generates multilingual XML sitemaps which adhere to Google's new The module generates multilingual XML sitemaps which adhere to Google's new
hreflang standard. Out of the box the sitemaps index most of Drupal's hreflang standard. Out of the box the sitemaps index most of Drupal's
...@@ -166,6 +167,9 @@ $generator ...@@ -166,6 +167,9 @@ $generator
->generateSitemap(); ->generateSitemap();
``` ```
See https://gbyte.co/projects/simple-xml-sitemap and code documentation in
Drupal\simple_sitemap\Simplesitemap for further details.
### API HOOKS ### ### API HOOKS ###
It is possible to hook into link generation by implementing It is possible to hook into link generation by implementing
...@@ -219,9 +223,11 @@ the settings array of the new generator plugin's annotation. See how the ...@@ -219,9 +223,11 @@ the settings array of the new generator plugin's annotation. See how the
EntityUrlGenerator is overwritten by the EntityMenuLinkContentUrlGenerator to EntityUrlGenerator is overwritten by the EntityMenuLinkContentUrlGenerator to
facilitate a different logic for menu links. facilitate a different logic for menu links.
See https://gbyte.co/projects/simple-xml-sitemap for further details.
## HOW CAN YOU CONTRIBUTE? ## ## HOW CAN YOU CONTRIBUTE? ##
* Report any bugs, feature or support requests in the issue tracker, if * Report any bugs, feature or support requests in the issue tracker; if
possible help out by submitting patches. possible help out by submitting patches.
http://drupal.org/project/issues/simple_sitemap http://drupal.org/project/issues/simple_sitemap
...@@ -231,6 +237,8 @@ facilitate a different logic for menu links. ...@@ -231,6 +237,8 @@ facilitate a different logic for menu links.
* If you would like to say thanks and support the development of this module, a * If you would like to say thanks and support the development of this module, a
donation will be much appreciated. donation will be much appreciated.
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W
* Feel free to contact me for paid support: https://gbyte.co/contact
## MAINTAINERS ## ## MAINTAINERS ##
......
...@@ -42,7 +42,6 @@ services: ...@@ -42,7 +42,6 @@ services:
- '@state' - '@state'
- '@module_handler' - '@module_handler'
- '@simple_sitemap.queue' - '@simple_sitemap.queue'
- '@lock'
simple_sitemap.queue: simple_sitemap.queue:
class: Drupal\simple_sitemap\Queue\SimplesitemapQueue class: Drupal\simple_sitemap\Queue\SimplesitemapQueue
......
...@@ -101,8 +101,10 @@ class EntityHelper { ...@@ -101,8 +101,10 @@ class EntityHelper {
} }
/** /**
* @param $url_object * @param \Drupal\Core\Url $url_object
* @return object|null * @return \Drupal\Core\Entity\EntityInterface|null
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/ */
public function getEntityFromUrlObject(Url $url_object) { public function getEntityFromUrlObject(Url $url_object) {
return $url_object->isRouted() return $url_object->isRouted()
...@@ -140,8 +142,8 @@ class EntityHelper { ...@@ -140,8 +142,8 @@ class EntityHelper {
} }
/** /**
* @param $entity_type_name * @param string $entity_type_name
* @param $entity_id * @param string $entity_id
* @return array * @return array
*/ */
public function getEntityImageUrls($entity_type_name, $entity_id) { public function getEntityImageUrls($entity_type_name, $entity_id) {
......
...@@ -12,6 +12,7 @@ use Drupal\simple_sitemap\Simplesitemap; ...@@ -12,6 +12,7 @@ use Drupal\simple_sitemap\Simplesitemap;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Session\AnonymousUserSession;
/** /**
* Class UrlGeneratorBase * Class UrlGeneratorBase
...@@ -19,8 +20,6 @@ use Drupal\Core\Language\Language; ...@@ -19,8 +20,6 @@ use Drupal\Core\Language\Language;
*/ */
abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGeneratorInterface { abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGeneratorInterface {
const ANONYMOUS_USER_ID = 0;
/** /**
* @var \Drupal\simple_sitemap\Simplesitemap * @var \Drupal\simple_sitemap\Simplesitemap
*/ */
...@@ -76,8 +75,6 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe ...@@ -76,8 +75,6 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\simple_sitemap\Logger $logger * @param \Drupal\simple_sitemap\Logger $logger
* @param \Drupal\simple_sitemap\EntityHelper $entityHelper * @param \Drupal\simple_sitemap\EntityHelper $entityHelper
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
...@@ -94,8 +91,7 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe ...@@ -94,8 +91,7 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
$this->languages = $language_manager->getLanguages(); $this->languages = $language_manager->getLanguages();
$this->defaultLanguageId = $language_manager->getDefaultLanguage()->getId(); $this->defaultLanguageId = $language_manager->getDefaultLanguage()->getId();
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->anonUser = $this->entityTypeManager->getStorage('user') $this->anonUser = new AnonymousUserSession();
->load(self::ANONYMOUS_USER_ID);
$this->logger = $logger; $this->logger = $logger;
$this->entityHelper = $entityHelper; $this->entityHelper = $entityHelper;
} }
......
...@@ -17,10 +17,8 @@ trait BatchTrait { ...@@ -17,10 +17,8 @@ trait BatchTrait {
/** /**
* @param string $from * @param string $from
* @param null $variants * @param array|null $variants
* @return bool * @return bool
*
* @todo Implement generating for certain variants only.
*/ */
public function batchGenerateSitemap($from = 'form', $variants = NULL) { public function batchGenerateSitemap($from = 'form', $variants = NULL) {
$this->batch = [ $this->batch = [
...@@ -56,6 +54,7 @@ trait BatchTrait { ...@@ -56,6 +54,7 @@ trait BatchTrait {
/** /**
* @param $context * @param $context
* @throws \Drupal\Component\Plugin\Exception\PluginException
* *
* @todo Make sure batch does not run at the same time as cron. * @todo Make sure batch does not run at the same time as cron.
* @todo Variants into generateSitemap(). * @todo Variants into generateSitemap().
......
...@@ -8,7 +8,6 @@ use Drupal\simple_sitemap\SimplesitemapSettings; ...@@ -8,7 +8,6 @@ use Drupal\simple_sitemap\SimplesitemapSettings;
use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandler;
use Drupal\simple_sitemap\SimplesitemapManager; use Drupal\simple_sitemap\SimplesitemapManager;
use Drupal\Core\State\State; use Drupal\Core\State\State;
use Drupal\Core\Lock\LockBackendInterface;
class QueueWorker { class QueueWorker {
...@@ -37,11 +36,6 @@ class QueueWorker { ...@@ -37,11 +36,6 @@ class QueueWorker {
*/ */
protected $moduleHandler; protected $moduleHandler;
/**
* @var \Drupal\Core\ProxyClass\Lock\DatabaseLockBackend
*/
protected $lock;
/** /**
* @var \Drupal\simple_sitemap\Queue\SimplesitemapQueue * @var \Drupal\simple_sitemap\Queue\SimplesitemapQueue
*/ */
...@@ -94,20 +88,17 @@ class QueueWorker { ...@@ -94,20 +88,17 @@ class QueueWorker {
* @param \Drupal\Core\State\State $state * @param \Drupal\Core\State\State $state
* @param \Drupal\Core\Extension\ModuleHandler $module_handler * @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @param \Drupal\simple_sitemap\Queue\SimplesitemapQueue $element_queue * @param \Drupal\simple_sitemap\Queue\SimplesitemapQueue $element_queue
* @param \Drupal\Core\Lock\LockBackendInterface $lock
*/ */
public function __construct(SimplesitemapSettings $settings, public function __construct(SimplesitemapSettings $settings,
SimplesitemapManager $manager, SimplesitemapManager $manager,
State $state, State $state,
ModuleHandler $module_handler, ModuleHandler $module_handler,
SimplesitemapQueue $element_queue, SimplesitemapQueue $element_queue) {
LockBackendInterface $lock) {
$this->settings = $settings; $this->settings = $settings;
$this->manager = $manager; $this->manager = $manager;
$this->state = $state; $this->state = $state;
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
$this->queue = $element_queue; $this->queue = $element_queue;
$this->lock = $lock;
} }
/** /**
...@@ -129,11 +120,9 @@ class QueueWorker { ...@@ -129,11 +120,9 @@ class QueueWorker {
} }
/** /**
* @param null $variants * @param array|null $variants
* @return $this * @return $this
* @throws \Drupal\Component\Plugin\Exception\PluginException * @throws \Drupal\Component\Plugin\Exception\PluginException
*
* @todo Lock functionality
*/ */
public function rebuildQueue($variants = NULL) { public function rebuildQueue($variants = NULL) {
$all_data_sets = []; $all_data_sets = [];
...@@ -199,9 +188,6 @@ class QueueWorker { ...@@ -199,9 +188,6 @@ class QueueWorker {
* @param string $from * @param string $from
* @return $this * @return $this
* @throws \Drupal\Component\Plugin\Exception\PluginException * @throws \Drupal\Component\Plugin\Exception\PluginException
*
* @todo Lock functionality
* @todo Does not unpublish sitemaps were variant does not have links anymore.
*/ */
public function generateSitemap($from = 'form') { public function generateSitemap($from = 'form') {
...@@ -266,6 +252,10 @@ class QueueWorker { ...@@ -266,6 +252,10 @@ class QueueWorker {
return $this; return $this;
} }
/**
* @param $element
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
protected function generateResultsFromElement($element) { protected function generateResultsFromElement($element) {
$results = $this->manager->getUrlGenerator($element->data['url_generator']) $results = $this->manager->getUrlGenerator($element->data['url_generator'])
->setSitemapVariant($this->variantProcessedNow) ->setSitemapVariant($this->variantProcessedNow)
...@@ -276,6 +266,9 @@ class QueueWorker { ...@@ -276,6 +266,9 @@ class QueueWorker {
$this->results = array_merge($this->results, $results); $this->results = array_merge($this->results, $results);
} }
/**
* @param array $results
*/
protected function removeDuplicates(&$results) { protected function removeDuplicates(&$results) {
if ($this->generatorSettings['remove_duplicates'] if ($this->generatorSettings['remove_duplicates']
&& !empty($results) && !empty($results)
...@@ -289,6 +282,10 @@ class QueueWorker { ...@@ -289,6 +282,10 @@ class QueueWorker {
} }
} }
/**
* @param bool $complete
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
protected function generateVariantChunksFromResults($complete = FALSE) { protected function generateVariantChunksFromResults($complete = FALSE) {
if (!empty($this->results)) { if (!empty($this->results)) {
$generator = $this->manager->getSitemapGenerator($this->generatorProcessedNow) $generator = $this->manager->getSitemapGenerator($this->generatorProcessedNow)
...@@ -351,6 +348,10 @@ class QueueWorker { ...@@ -351,6 +348,10 @@ class QueueWorker {
return $this->elementsTotal; return $this->elementsTotal;
} }
/**
* @param bool $force_recount
* @return int
*/
public function getQueuedElementCount($force_recount = FALSE) { public function getQueuedElementCount($force_recount = FALSE) {
if ($force_recount || NULL === $this->elementsRemaining) { if ($force_recount || NULL === $this->elementsRemaining) {
$this->elementsRemaining = $this->queue->numberOfItems(); $this->elementsRemaining = $this->queue->numberOfItems();
...@@ -359,10 +360,16 @@ class QueueWorker { ...@@ -359,10 +360,16 @@ class QueueWorker {
return $this->elementsRemaining; return $this->elementsRemaining;
} }
/**
* @return int
*/
public function getStashedResultCount() { public function getStashedResultCount() {
return count($this->state->get('simple_sitemap.queue_stashed_results', ['results' => []])['results']); return count($this->state->get('simple_sitemap.queue_stashed_results', ['results' => []])['results']);
} }
/**
* @return int
*/
public function getProcessedElementCount() { public function getProcessedElementCount() {
$initial = $this->getInitialElementCount(); $initial = $this->getInitialElementCount();
$remaining = $this->getQueuedElementCount(); $remaining = $this->getQueuedElementCount();
...@@ -370,6 +377,9 @@ class QueueWorker { ...@@ -370,6 +377,9 @@ class QueueWorker {
return $initial > $remaining ? ($initial - $remaining) : 0; return $initial > $remaining ? ($initial - $remaining) : 0;
} }
/**
* @return bool
*/
public function generationInProgress() { public function generationInProgress() {
return 0 < ($this->getQueuedElementCount() + $this->getStashedResultCount()); return 0 < ($this->getQueuedElementCount() + $this->getStashedResultCount());
} }
......
...@@ -167,6 +167,7 @@ class Simplesitemap { ...@@ -167,6 +167,7 @@ class Simplesitemap {
* *
* @param string $name * @param string $name
* Setting name, like 'max_links'. * Setting name, like 'max_links'.
*
* @param mixed $setting * @param mixed $setting
* The setting to be saved. * The setting to be saved.
* *
...@@ -216,7 +217,12 @@ class Simplesitemap { ...@@ -216,7 +217,12 @@ class Simplesitemap {
} }
/** /**
* Gets the currently set variants, the default variant, or all variants.
*
* @param bool $default_get_all * @param bool $default_get_all
* If true and no variants are set, all variants are returned. If false and
* no variants are set, only the default variant is returned.
*
* @return array * @return array
*/ */
protected function getVariants($default_get_all = TRUE) { protected function getVariants($default_get_all = TRUE) {
...@@ -268,7 +274,8 @@ class Simplesitemap { ...@@ -268,7 +274,8 @@ class Simplesitemap {
* *
* @return array * @return array
* An array containing all published sitemap chunk IDs, deltas and creation * An array containing all published sitemap chunk IDs, deltas and creation
* timestamps keyed by their variant ID. * timestamps keyed by the currently set variants, or in case of only one
* variant set the above keyed by sitemap delta.
*/ */
protected function fetchSitemapVariantInfo() { protected function fetchSitemapVariantInfo() {
$result = $this->db->select('simple_sitemap', 's') $result = $this->db->select('simple_sitemap', 's')
...@@ -297,6 +304,8 @@ class Simplesitemap { ...@@ -297,6 +304,8 @@ class Simplesitemap {
} }
/** /**
* Removes sitemap instances for the currently set variants.
*
* @return $this * @return $this
* @throws \Drupal\Component\Plugin\Exception\PluginException * @throws \Drupal\Component\Plugin\Exception\PluginException
*/ */
...@@ -307,11 +316,17 @@ class Simplesitemap { ...@@ -307,11 +316,17 @@ class Simplesitemap {
} }
/** /**
* Generates all sitemaps.
*
* @param string $from * @param string $from
* Can be 'form', 'drush', 'cron' and 'backend'.
*
* @return $this * @return $this
*
* @throws \Drupal\Component\Plugin\Exception\PluginException * @throws \Drupal\Component\Plugin\Exception\PluginException
* *
* @todo variants * @todo Respect $this->variants and generate for specific variants.
* @todo Implement lock functionality.
*/ */
public function generateSitemap($from = 'form') { public function generateSitemap($from = 'form') {
switch($from) { switch($from) {
...@@ -329,6 +344,12 @@ class Simplesitemap { ...@@ -329,6 +344,12 @@ class Simplesitemap {
return $this; return $this;
} }
/**
* Rebuilds the queue for the currently set variants.
*
* @return $this
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
public function rebuildQueue() { public function rebuildQueue() {
$this->queueWorker->rebuildQueue($this->getVariants()); $this->queueWorker->rebuildQueue($this->getVariants());
...@@ -342,17 +363,15 @@ class Simplesitemap { ...@@ -342,17 +363,15 @@ class Simplesitemap {
* *
* @return string|array|false * @return string|array|false
* Formatted timestamp of last sitemap generation, otherwise FALSE. * Formatted timestamp of last sitemap generation, otherwise FALSE.
*
* @todo: variants
*/ */
public function getGeneratedAgo() { /* public function getGeneratedAgo() {
$chunks = $this->fetchSitemapVariantInfo(); $chunks = $this->fetchSitemapVariantInfo();
return isset($chunks[DefaultSitemapGenerator::FIRST_CHUNK_DELTA]->sitemap_created) return isset($chunks[DefaultSitemapGenerator::FIRST_CHUNK_DELTA]->sitemap_created)
? $this->dateFormatter ? $this->dateFormatter
->formatInterval($this->time->getRequestTime() - $chunks[DefaultSitemapGenerator::FIRST_CHUNK_DELTA] ->formatInterval($this->time->getRequestTime() - $chunks[DefaultSitemapGenerator::FIRST_CHUNK_DELTA]
->sitemap_created) ->sitemap_created)
: FALSE; : FALSE;
} }*/
/** /**
* Enables sitemap support for an entity type. Enabled entity types show * Enables sitemap support for an entity type. Enabled entity types show
...@@ -380,7 +399,6 @@ class Simplesitemap { ...@@ -380,7 +399,6 @@ class Simplesitemap {
* settings from entity forms. * settings from entity forms.
* *
* @param string $entity_type_id * @param string $entity_type_id
* Entity type id like 'node'.
* *
* @return $this * @return $this
*/ */
...@@ -409,19 +427,18 @@ class Simplesitemap { ...@@ -409,19 +427,18 @@ class Simplesitemap {
} }
/** /**
* Sets sitemap settings for a non-bundle entity type (e.g. user) or a bundle * Sets settings for bundle or non-bundle entity types. This is done for the
* of an entity type (e.g. page). * currently set variant.
* *
* @param string $entity_type_id * @param $entity_type_id
* Entity type id like 'node' the bundle belongs to. * @param null $bundle_name
* @param string $bundle_name
* Name of the bundle. NULL if entity type has no bundles.
* @param array $settings * @param array $settings
* An array of sitemap settings for this bundle/entity type.
* Example: ['index' => TRUE, 'priority' => 0.5, 'changefreq' => 'never', 'include_images' => FALSE].
* *
* @return $this * @return $this
* *
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*
* @todo: enableEntityType automatically * @todo: enableEntityType automatically
* @todo multiple variants * @todo multiple variants
*/ */
...@@ -482,18 +499,18 @@ class Simplesitemap { ...@@ -482,18 +499,18 @@ class Simplesitemap {
} }
/** /**
* Gets sitemap settings for an entity bundle, a non-bundle entity type or for * Gets settings for bundle or non-bundle entity types. This is done for the
* all entity types and their bundles. * currently set variants.
* *
* @param string|null $entity_type_id * @param string|null $entity_type_id
* If set to null, sitemap settings for all entity types and their bundles * Limit the result set to a specific entity type.
* are fetched. *
* @param string|null $bundle_name * @param string|null $bundle_name
* Limit the result set to a specific bundle name.
* *
* @return array|false * @return array|false
* Array of sitemap settings for an entity bundle, a non-bundle entity type * Array of settings or array of settings keyed by variant name. False if
* or for all entity types and their bundles. * entity type does not exist.
* False if entity type does not exist.
*/ */
public function getBundleSettings($entity_type_id = NULL, $bundle_name = NULL, $supplement_defaults = TRUE, $multiple_variants = FALSE) { public function getBundleSettings($entity_type_id = NULL, $bundle_name = NULL, $supplement_defaults = TRUE, $multiple_variants = FALSE) {
...@@ -553,9 +570,19 @@ class Simplesitemap { ...@@ -553,9 +570,19 @@ class Simplesitemap {
} }
/** /**
* Removes settings for bundle or a non-bundle entity types. This is done for
* the currently set variants.
*
* @param string|null $entity_type_id * @param string|null $entity_type_id
* Limit the removal to a specific entity type.
*
* @param string|null $bundle_name * @param string|null $bundle_name
* Limit the removal to a specific bundle name.
*
* @return $this * @return $this
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/ */
public function removeBundleSettings($entity_type_id = NULL, $bundle_name = NULL) { public function removeBundleSettings($entity_type_id = NULL, $bundle_name = NULL) {
if (empty($variants = $this->getVariants(FALSE))) { if (empty($variants = $this->getVariants(FALSE))) {
...@@ -593,7 +620,8 @@ class Simplesitemap { ...@@ -593,7 +620,8 @@ class Simplesitemap {
* Supplements all missing link setting with default values. * Supplements all missing link setting with default values.
* *
* @param string $type * @param string $type
* 'entity'|'custom' * Can be 'entity' or 'custom'.
*
* @param array &$settings * @param array &$settings
* @param array $overrides * @param array $overrides
*/ */
...@@ -609,13 +637,17 @@ class Simplesitemap { ...@@ -609,13 +637,17 @@ class Simplesitemap {
} }
/** /**
* Overrides entity bundle/entity type sitemap settings for a single entity. * Overrides sitemap settings for a single entity for the currently set
* variants.
* *
* @param string $entity_type_id * @param string $entity_type_id
* @param int $id * @param string $id
* @param array $settings * @param array $settings
* *
* @return $this * @return $this
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/ */
public function setEntityInstanceSettings($entity_type_id, $id, $settings) { public function setEntityInstanceSettings($entity_type_id, $id, $settings) {
if (empty($variants = $this->getVariants(FALSE))) { if (empty($variants = $this->getVariants(FALSE))) {
...@@ -665,13 +697,19 @@ class Simplesitemap { ...@@ -665,13 +697,19 @@ class Simplesitemap {
} }
/** /**
* Gets sitemap settings for an entity instance which overrides the sitemap * Gets sitemap settings for an entity instance which overrides bundle
* settings of its bundle, or bundle settings, if they are not overridden. * settings, or gets bundle settings, if they are not overridden. This is
* done for the currently set variant.
* *
* @param string $entity_type_id * @param string $entity_type_id
* @param int $id * @param string $id
* *
* @return array|false * @return array|false
* Array of entity instance settings or the settings of its bundle. False if
* entity type does not exist.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* *
* @todo multiple variants * @todo multiple variants
*/ */
...@@ -702,11 +740,14 @@ class Simplesitemap { ...@@ -702,11 +740,14 @@ class Simplesitemap {
} }
/** /**
* Removes sitemap settings for an entity that overrides the sitemap settings * Removes sitemap settings for entities that override bundle settings. This
* of its bundle. * is done for the currently set variants.
*
* @param string|null $entity_type_id
* Limits the removal to a certain entity type.
* *
* @param string $entity_type_id
* @param string|null $entity_ids * @param string|null $entity_ids
* Limits the removal to entities with certain IDs.
* *
* @return $this * @return $this
*/ */
...@@ -733,12 +774,14 @@ class Simplesitemap { ...@@ -733,12 +774,14 @@ class Simplesitemap {
/** /**
* Checks if an entity bundle (or a non-bundle entity type) is set to be * Checks if an entity bundle (or a non-bundle entity type) is set to be
* indexed in the sitemap settings. * indexed for the currently set variant.
* *
* @param string $entity_type_id * @param string $entity_type_id
* @param string|null $bundle_name * @param string|null $bundle_name
* *
* @return bool * @return bool
*
* @todo multiple variants?
*/ */
public function bundleIsIndexed($entity_type_id, $bundle_name = NULL) { public function bundleIsIndexed($entity_type_id, $bundle_name = NULL) {
$settings = $this->getBundleSettings($entity_type_id, $bundle_name); $settings = $this->getBundleSettings($entity_type_id, $bundle_name);
...@@ -757,10 +800,13 @@ class Simplesitemap { ...@@ -757,10 +800,13 @@ class Simplesitemap {
} }
/** /**
* Stores a custom path along with its sitemap settings to configuration. * Stores a custom path along with its settings to configuration for the
* currently set variants.
* *
* @param string $path * @param string $path
*
* @param array $settings * @param array $settings
* Settings that are not provided are supplemented by defaults.
* *
* @return $this * @return $this
* *
...@@ -804,10 +850,19 @@ class Simplesitemap { ...@@ -804,10 +850,19 @@ class Simplesitemap {
} }
/** /**
* Returns an array of custom paths and their sitemap settings. * Gets custom link settings for the currently set variants.
*
* @param string|null $path