public function ViewsUrlGenerator::getDataSets in Simple XML sitemap 8.3
Same name and namespace in other branches
- 4.x modules/simple_sitemap_views/src/Plugin/simple_sitemap/UrlGenerator/ViewsUrlGenerator.php \Drupal\simple_sitemap_views\Plugin\simple_sitemap\UrlGenerator\ViewsUrlGenerator::getDataSets()
Return value
mixed
Overrides UrlGeneratorBase::getDataSets
File
- modules/
simple_sitemap_views/ src/ Plugin/ simple_sitemap/ UrlGenerator/ ViewsUrlGenerator.php, line 114
Class
- ViewsUrlGenerator
- Views URL generator plugin.
Namespace
Drupal\simple_sitemap_views\Plugin\simple_sitemap\UrlGeneratorCode
public function getDataSets() {
$data_sets = [];
// Get data sets.
foreach ($this->sitemapViews
->getIndexableViews() as $view) {
$settings = $this->sitemapViews
->getSitemapSettings($view, $this->sitemapVariant);
if (empty($settings)) {
$view
->destroy();
continue;
}
$base_data_set = [
'view_id' => $view
->id(),
'display_id' => $view->current_display,
];
$extender = $this->sitemapViews
->getDisplayExtender($view);
// View path without arguments.
if (!$extender
->hasRequiredArguments()) {
$data_sets[] = $base_data_set + [
'arguments' => NULL,
];
}
// Process indexed arguments.
if ($args_ids = $this->sitemapViews
->getIndexableArguments($view, $this->sitemapVariant)) {
$args_ids = $this->sitemapViews
->getArgumentsStringVariations($args_ids);
// Form the condition according to the variants of the
// indexable arguments.
$condition = Database::getConnection()
->condition('AND');
$condition
->condition('view_id', $view
->id());
$condition
->condition('display_id', $view->current_display);
$condition
->condition('arguments_ids', $args_ids, 'IN');
// Get the arguments values from the index.
$max_links = is_numeric($settings['max_links']) ? $settings['max_links'] : NULL;
$indexed_arguments = $this->sitemapViews
->getArgumentsFromIndex($condition, $max_links, TRUE);
// Add the arguments values for processing.
foreach ($indexed_arguments as $index_id => $arguments_info) {
$data_sets[] = $base_data_set + [
'index_id' => $index_id,
'arguments' => $arguments_info['arguments'],
];
}
}
// Destroy a view instance.
$view
->destroy();
}
return $data_sets;
}