function xmlsitemap_rebuild_batch in XML sitemap 8
Same name and namespace in other branches
- 6.2 xmlsitemap.generate.inc \xmlsitemap_rebuild_batch()
- 7.2 xmlsitemap.generate.inc \xmlsitemap_rebuild_batch()
- 2.x xmlsitemap.module \xmlsitemap_rebuild_batch()
Batch information callback for rebuilding the sitemap data.
Parameters
array $entity_type_ids: Entity types to rebuild.
bool $save_custom: Save custom data.
Return value
array Batch array.
3 calls to xmlsitemap_rebuild_batch()
- drush_xmlsitemap_rebuild in ./
xmlsitemap.drush.inc - Dump and rebuild all the sitemap data, then regenerate the files.
- XmlSitemapCommands::rebuild in src/
Commands/ XmlSitemapCommands.php - Dump and re-process all possible XML sitemap data, then regenerate files.
- XmlSitemapRebuildForm::submitForm in src/
Form/ XmlSitemapRebuildForm.php - Form submission handler.
File
- ./
xmlsitemap.module, line 2523 - xmlsitemap XML sitemap
Code
function xmlsitemap_rebuild_batch(array $entity_type_ids, $save_custom = FALSE) {
$batch = [
'operations' => [],
'finished' => 'xmlsitemap_rebuild_batch_finished',
'title' => t('Rebuilding Sitemap'),
'file' => drupal_get_path('module', 'xmlsitemap') . '/xmlsitemap.generate.inc',
];
// Set the rebuild flag in case something fails during the rebuild.
$batch['operations'][] = [
'xmlsitemap_batch_variable_set',
[
[
'xmlsitemap_rebuild_needed' => TRUE,
],
],
];
// Purge any links first.
$batch['operations'][] = [
'xmlsitemap_rebuild_batch_clear',
[
$entity_type_ids,
(bool) $save_custom,
],
];
// Fetch all the sitemap links and save them to the {xmlsitemap} table.
foreach ($entity_type_ids as $entity_type_id) {
$info = xmlsitemap_get_link_info($entity_type_id);
$batch['operations'][] = [
$info['xmlsitemap']['rebuild callback'],
[
$entity_type_id,
],
];
}
// Clear the rebuild flag.
$batch['operations'][] = [
'xmlsitemap_batch_variable_set',
[
[
'xmlsitemap_rebuild_needed' => FALSE,
],
],
];
// Add the regeneration batch.
$regenerate_batch = xmlsitemap_regenerate_batch();
$batch['operations'] = array_merge($batch['operations'], $regenerate_batch['operations']);
return $batch;
}