constPATH_DOES_NOT_EXIST_OR_NO_ACCESS="The path @path has been omitted from the XML sitemap as it either does not exist, or it is not accessible to anonymous users.";
protected$sitemapGenerator;
protected$languages;
protected$entityTypeManager;
protected$pathValidator;
protected$entityQuery;
protected$anonUser;
publicfunction__construct(
$sitemap_generator,
$language_manager,
$entity_type_manager,
$path_validator,
$entity_query
){
$this->sitemapGenerator=$sitemap_generator;//todo using only one method, maybe make method static instead?
case'menu_link_content':// Loading url object for menu links.
if(!$entity->isEnabled())
continue;
$url_object=$entity->getUrlObject();
break;
default:// Loading url object for other entities.
$url_object=$entity->toUrl();//todo: file entity type does not have a canonical url and breaks generation, hopefully fixed in https://www.drupal.org/node/2402533
}
// Do not include external paths.
if(!$url_object->isRouted())
continue;
// Do not include paths inaccessible to anonymous users.
if(!$url_object->access($this->anonUser))
continue;
// Do not include paths that have been already indexed.
if(!$this->pathValidator->isValid($custom_path['path'])){//todo: Change to different function, as this also checks if current user has access. The user however varies depending if process was started from the web interface or via cron/drush. Use getUrlIfValidWithoutAccessCheck()?