protected function EntityUrlGenerator::processDataSet in Simple XML sitemap 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGenerator::processDataSet()
- 4.x src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGenerator::processDataSet()
@inheritdoc
Overrides UrlGeneratorBase::processDataSet
File
- src/
Plugin/ simple_sitemap/ UrlGenerator/ EntityUrlGenerator.php, line 129
Class
- EntityUrlGenerator
- Class EntityUrlGenerator @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
Namespace
Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGeneratorCode
protected function processDataSet($entity) {
$entity_id = $entity
->id();
$entity_type_name = $entity
->getEntityTypeId();
$entity_settings = $this->generator
->getEntityInstanceSettings($entity_type_name, $entity_id);
if (empty($entity_settings['index'])) {
return FALSE;
}
$url_object = $entity
->toUrl();
// Do not include external paths.
if (!$url_object
->isRouted()) {
return FALSE;
}
$path = $url_object
->getInternalPath();
// Do not include paths that have been already indexed.
if ($this->batchSettings['remove_duplicates'] && $this
->pathProcessed($path)) {
return FALSE;
}
$url_object
->setOption('absolute', TRUE);
return [
'url' => $url_object,
'lastmod' => method_exists($entity, 'getChangedTime') ? date_iso8601($entity
->getChangedTime()) : NULL,
'priority' => isset($entity_settings['priority']) ? $entity_settings['priority'] : NULL,
'changefreq' => !empty($entity_settings['changefreq']) ? $entity_settings['changefreq'] : NULL,
'images' => !empty($entity_settings['include_images']) ? $this
->getImages($entity_type_name, $entity_id) : [],
// Additional info useful in hooks.
'meta' => [
'path' => $path,
'entity_info' => [
'entity_type' => $entity_type_name,
'id' => $entity_id,
],
],
];
}