protected function ViewsUrlGenerator::processDataSet in Simple XML sitemap (Views integration) 8
File
- src/
Plugin/ simple_sitemap/ UrlGenerator/ ViewsUrlGenerator.php, line 200 - Contains Views URL generator.
Class
- ViewsUrlGenerator
- Views URL generator plugin.
Namespace
Drupal\simple_sitemap_views\Plugin\simple_sitemap\UrlGeneratorCode
protected function processDataSet($data_set) {
/** @var \Drupal\views\ViewExecutable $view */
$view = $data_set['view'];
$settings = $data_set['settings'];
$args = $data_set['arguments'];
// Get view display path.
try {
$url = $view
->getUrl($args);
$url
->setAbsolute();
if (is_array($args)) {
$this
->cleanRouteParameters($url, $args);
}
$path = $url
->getInternalPath();
} catch (\InvalidArgumentException $e) {
$this
->markIndexToDelete($data_set);
return FALSE;
} catch (\UnexpectedValueException $e) {
$this
->markIndexToDelete($data_set);
return FALSE;
}
// Do not include paths that have been already indexed.
if ($this->batchSettings['remove_duplicates'] && $this
->pathProcessed($path)) {
return FALSE;
}
if (is_array($args)) {
$params = array_merge([
$view
->id(),
$view->current_display,
], $args);
$view_result = call_user_func_array('views_get_view_result', $params);
// Do not include paths on which the view returns an empty result.
if (empty($view_result)) {
$this
->markIndexToDelete($data_set);
return FALSE;
}
}
return [
'url' => $url,
'lastmod' => NULL,
'priority' => isset($settings['priority']) ? $settings['priority'] : NULL,
'changefreq' => !empty($settings['changefreq']) ? $settings['changefreq'] : NULL,
'images' => [],
// Additional info useful in hooks.
'meta' => [
'path' => $path,
'view_info' => [
'view_id' => $view
->id(),
'display_id' => $view->current_display,
'arguments' => $args,
],
],
];
}