function simplesitemap_entity_form_submit in Simple XML sitemap 8
Form submission handler called in hook_form_alter.
1 string reference to 'simplesitemap_entity_form_submit'
- simplesitemap_form_alter in ./
simplesitemap.module - Implements hook_form_alter.
File
- ./
simplesitemap.module, line 80 - Main module file containing hooks.
Code
function simplesitemap_entity_form_submit($form, &$form_state) {
$sitemap = new Simplesitemap();
$values = $form_state
->getValues();
// Only make changes in DB if sitemap settings actually changed.
if ($values['simplesitemap_index_content'] != $form['simplesitemap']['simplesitemap_index_content']['#default_value'] || $values['simplesitemap_priority'] != $form['simplesitemap']['simplesitemap_priority']['#default_value']) {
$entity_type_id = $form['#simplesitemap']['entity_type_id'];
$bundle_name = $form['#simplesitemap']['bundle_name'];
// Get current entity type sitemap settings.
$entity_types = $sitemap
->get_config('entity_types');
$entity_types[$entity_type_id][$bundle_name]['index'] = $values['simplesitemap_index_content'];
$entity_types[$entity_type_id][$bundle_name]['priority'] = $values['simplesitemap_priority'];
// Save new entity type settings.
$sitemap
->save_config('entity_types', $entity_types);
}
// Regenerate sitemaps according to user setting.
if ($values['simplesitemap_regenerate_now']) {
$sitemap
->generate_sitemap();
drupal_set_message(t("The <a href='@url' target='_blank'>XML sitemap</a> has been regenerated for all languages.", array(
'@url' => $GLOBALS['base_url'] . '/sitemap.xml',
)));
}
}