function simple_sitemap_entity_form_submit in Simple XML sitemap 8.2
Same name and namespace in other branches
- 8.3 simple_sitemap.module \simple_sitemap_entity_form_submit()
- 4.x simple_sitemap.module \simple_sitemap_entity_form_submit()
Form submission handler called in hook_form_alter.
Parameters
$form:
\Drupal\Core\Form\FormStateInterface $form_state:
1 string reference to 'simple_sitemap_entity_form_submit'
- simple_sitemap_form_alter in ./
simple_sitemap.module - Implements hook_form_alter.
File
- ./
simple_sitemap.module, line 89 - Main module file containing hooks.
Code
function simple_sitemap_entity_form_submit($form, FormStateInterface &$form_state) {
/**
* @var Drupal\simple_sitemap\Form\FormHelper $f
*/
$f = \Drupal::service('simple_sitemap.form_helper');
if (!$f
->processForm($form_state)) {
return;
}
$values = $form_state
->getValues();
// Fix for values appearing in a sub array on a commerce product entity.
$values = isset($values['simple_sitemap']) ? $values['simple_sitemap'] : $values;
// Only make changes in DB if sitemap settings actually changed.
if ($f
->valuesChanged($form, $values)) {
/**
* @var \Drupal\simple_sitemap\Simplesitemap $generator
*/
$generator = \Drupal::service('simple_sitemap.generator');
$settings = [
'index' => $values['simple_sitemap_index_content'],
'priority' => $values['simple_sitemap_priority'],
'changefreq' => $values['simple_sitemap_changefreq'],
'include_images' => $values['simple_sitemap_include_images'],
];
switch ($f
->getEntityCategory()) {
case 'bundle':
$generator
->setBundleSettings($f
->getEntityTypeId(), !empty($f
->getBundleName()) ? $f
->getBundleName() : $f
->getFormEntityId(), $settings);
break;
case 'instance':
$generator
->setEntityInstanceSettings($f
->getEntityTypeId(), !empty($f
->getInstanceId()) ? $f
->getInstanceId() : $f
->getFormEntityId(), $settings);
break;
}
// Regenerate sitemaps according to user setting.
if ($values['simple_sitemap_regenerate_now']) {
$generator
->generateSitemap();
}
}
}