public function XmlSitemapEntitiesSettingsForm::submitForm in XML sitemap 8
Same name and namespace in other branches
- 2.x src/Form/XmlSitemapEntitiesSettingsForm.php \Drupal\xmlsitemap\Form\XmlSitemapEntitiesSettingsForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ XmlSitemapEntitiesSettingsForm.php, line 184
Class
- XmlSitemapEntitiesSettingsForm
- Configure what entities will be included in sitemap.
Namespace
Drupal\xmlsitemap\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$bundles = $this->entityTypeBundleInfo
->getAllBundleInfo();
$values = $form_state
->getValues();
$entity_values = $values['entity_types'];
foreach ($entity_values as $key => $value) {
if ($value) {
foreach ($bundles[$key] as $bundle_key => $bundle_value) {
if (!$values['settings'][$key]['types'][$bundle_key]) {
xmlsitemap_link_bundle_delete($key, $bundle_key, TRUE);
}
elseif (!xmlsitemap_link_bundle_check_enabled($key, $bundle_key)) {
xmlsitemap_link_bundle_enable($key, $bundle_key);
}
}
}
else {
foreach ($bundles[$key] as $bundle_key => $bundle_value) {
xmlsitemap_link_bundle_delete($key, $bundle_key, TRUE);
}
}
}
$this->state
->set('xmlsitemap_regenerate_needed', TRUE);
parent::submitForm($form, $form_state);
}