Loading src/Plugin/simple_sitemap/UrlGenerator/CustomUrlGenerator.php +6 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator; use Drupal\Core\Url; use Drupal\Component\Utility\UrlHelper; use Drupal\simple_sitemap\Entity\EntityHelper; use Drupal\simple_sitemap\Exception\SkipElementException; use Drupal\simple_sitemap\Logger; Loading Loading @@ -147,7 +148,6 @@ class CustomUrlGenerator extends EntityUrlGeneratorBase { } $url_object = Url::fromUserInput($data_set['path'])->setAbsolute(); $path = $url_object->getInternalPath(); $entity = $this->entityHelper->getEntityFromUrlObject($url_object); Loading @@ -162,10 +162,14 @@ class CustomUrlGenerator extends EntityUrlGeneratorBase { ? $this->getEntityImageData($entity) : [], 'meta' => [ 'path' => $path, 'path' => $this->getInternalPathWithQuery($url_object), ], ]; if (($query = $url_object->getOption('query')) && is_array($query)) { $path_data['meta']['query'] = UrlHelper::buildQuery($query); } // Additional info useful in hooks. if (!empty($entity)) { $path_data['meta']['entity_info'] = [ Loading src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php +6 −8 Original line number Diff line number Diff line Loading @@ -191,19 +191,17 @@ class EntityMenuLinkContentUrlGenerator extends EntityUrlGeneratorBase { throw new SkipElementException(); } $path = $url_object->getInternalPath(); $path = $this->getInternalPathWithQuery($url_object); } // There can be internal paths that are not rooted, like 'base:/path'. else { elseif (strpos($uri = $url_object->toUriString(), 'base:/') === 0) { // Handle base scheme. if (strpos($uri = $url_object->toUriString(), 'base:/') === 0) { $path = $uri[6] === '/' ? substr($uri, 7) : substr($uri, 6); } // Handle unforeseen schemes. else { // Handle unforeseen schemes. $path = $uri; } } $entity = $this->entityHelper->getEntityFromUrlObject($url_object); Loading src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php +1 −1 Original line number Diff line number Diff line Loading @@ -276,7 +276,7 @@ class EntityUrlGenerator extends EntityUrlGeneratorBase { // Additional info useful in hooks. 'meta' => [ 'path' => $url_object->getInternalPath(), 'path' => $this->getInternalPathWithQuery($url_object), 'entity_info' => [ 'entity_type' => $entity->getEntityTypeId(), 'id' => $entity->id(), Loading src/Plugin/simple_sitemap/UrlGenerator/UrlGeneratorBase.php +19 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Url; use Drupal\simple_sitemap\Exception\SkipElementException; use Drupal\simple_sitemap\Plugin\simple_sitemap\SimpleSitemapPluginBase; use Drupal\simple_sitemap\Entity\SimpleSitemapInterface; Loading Loading @@ -98,6 +100,23 @@ abstract class UrlGeneratorBase extends SimpleSitemapPluginBase implements UrlGe : $url; } /** * Gets the internal path with URL query from a URL object. * * @param \Drupal\Core\Url $url * URL object. * * @return string * Internal path with URL query. */ protected function getInternalPathWithQuery(Url $url): string { if (($query = $url->getOption('query')) && is_array($query)) { return $url->getInternalPath() . '?' . UrlHelper::buildQuery($query); } return $url->getInternalPath(); } /** * {@inheritdoc} */ Loading src/Queue/QueueWorker.php +9 −7 Original line number Diff line number Diff line Loading @@ -371,13 +371,15 @@ class QueueWorker { */ protected function removeDuplicates(array &$results): void { if ($this->generatorSettings['remove_duplicates'] && !empty($results)) { $result = $results[key($results)]; foreach ($results as $key => $result) { if (isset($result['meta']['path'])) { if (isset($this->processedPaths[$result['meta']['path']])) { $results = []; $path = $result['meta']['path']; if (isset($this->processedPaths[$path])) { unset($results[$key]); } else { $this->processedPaths[$result['meta']['path']] = TRUE; $this->processedPaths[$path] = TRUE; } } } } Loading Loading
src/Plugin/simple_sitemap/UrlGenerator/CustomUrlGenerator.php +6 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator; use Drupal\Core\Url; use Drupal\Component\Utility\UrlHelper; use Drupal\simple_sitemap\Entity\EntityHelper; use Drupal\simple_sitemap\Exception\SkipElementException; use Drupal\simple_sitemap\Logger; Loading Loading @@ -147,7 +148,6 @@ class CustomUrlGenerator extends EntityUrlGeneratorBase { } $url_object = Url::fromUserInput($data_set['path'])->setAbsolute(); $path = $url_object->getInternalPath(); $entity = $this->entityHelper->getEntityFromUrlObject($url_object); Loading @@ -162,10 +162,14 @@ class CustomUrlGenerator extends EntityUrlGeneratorBase { ? $this->getEntityImageData($entity) : [], 'meta' => [ 'path' => $path, 'path' => $this->getInternalPathWithQuery($url_object), ], ]; if (($query = $url_object->getOption('query')) && is_array($query)) { $path_data['meta']['query'] = UrlHelper::buildQuery($query); } // Additional info useful in hooks. if (!empty($entity)) { $path_data['meta']['entity_info'] = [ Loading
src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php +6 −8 Original line number Diff line number Diff line Loading @@ -191,19 +191,17 @@ class EntityMenuLinkContentUrlGenerator extends EntityUrlGeneratorBase { throw new SkipElementException(); } $path = $url_object->getInternalPath(); $path = $this->getInternalPathWithQuery($url_object); } // There can be internal paths that are not rooted, like 'base:/path'. else { elseif (strpos($uri = $url_object->toUriString(), 'base:/') === 0) { // Handle base scheme. if (strpos($uri = $url_object->toUriString(), 'base:/') === 0) { $path = $uri[6] === '/' ? substr($uri, 7) : substr($uri, 6); } // Handle unforeseen schemes. else { // Handle unforeseen schemes. $path = $uri; } } $entity = $this->entityHelper->getEntityFromUrlObject($url_object); Loading
src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php +1 −1 Original line number Diff line number Diff line Loading @@ -276,7 +276,7 @@ class EntityUrlGenerator extends EntityUrlGeneratorBase { // Additional info useful in hooks. 'meta' => [ 'path' => $url_object->getInternalPath(), 'path' => $this->getInternalPathWithQuery($url_object), 'entity_info' => [ 'entity_type' => $entity->getEntityTypeId(), 'id' => $entity->id(), Loading
src/Plugin/simple_sitemap/UrlGenerator/UrlGeneratorBase.php +19 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Url; use Drupal\simple_sitemap\Exception\SkipElementException; use Drupal\simple_sitemap\Plugin\simple_sitemap\SimpleSitemapPluginBase; use Drupal\simple_sitemap\Entity\SimpleSitemapInterface; Loading Loading @@ -98,6 +100,23 @@ abstract class UrlGeneratorBase extends SimpleSitemapPluginBase implements UrlGe : $url; } /** * Gets the internal path with URL query from a URL object. * * @param \Drupal\Core\Url $url * URL object. * * @return string * Internal path with URL query. */ protected function getInternalPathWithQuery(Url $url): string { if (($query = $url->getOption('query')) && is_array($query)) { return $url->getInternalPath() . '?' . UrlHelper::buildQuery($query); } return $url->getInternalPath(); } /** * {@inheritdoc} */ Loading
src/Queue/QueueWorker.php +9 −7 Original line number Diff line number Diff line Loading @@ -371,13 +371,15 @@ class QueueWorker { */ protected function removeDuplicates(array &$results): void { if ($this->generatorSettings['remove_duplicates'] && !empty($results)) { $result = $results[key($results)]; foreach ($results as $key => $result) { if (isset($result['meta']['path'])) { if (isset($this->processedPaths[$result['meta']['path']])) { $results = []; $path = $result['meta']['path']; if (isset($this->processedPaths[$path])) { unset($results[$key]); } else { $this->processedPaths[$result['meta']['path']] = TRUE; $this->processedPaths[$path] = TRUE; } } } } Loading