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.";
constBATCH_INIT_MESSAGE='Initializing batch...';
constBATCH_ERROR_MESSAGE='An error has occurred. This may result in an incomplete XML sitemap.';
constBATCH_PROGRESS_MESSAGE='Processing @current out of @total link types.';
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($anon_user))
continue;
// Do not include paths that have been already indexed.
if(!\Drupal::service('path.validator')->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()?