public function PathautoSettingsForm::submitForm in Pathauto 8
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/ PathautoSettingsForm.php, line 294
Class
- PathautoSettingsForm
- Configure pathauto settings for this site.
Namespace
Drupal\pathauto\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('pathauto.settings');
$form_state
->cleanValues();
foreach ($form_state
->getValues() as $key => $value) {
if ($key == 'enabled_entity_types') {
$enabled_entity_types = [];
foreach ($value as $entity_type_id => $enabled) {
$field_definitions = $this->entityFieldManager
->getBaseFieldDefinitions($entity_type_id);
// Verify that the entity type is enabled and that it is not defined
// or defined by us before adding it to the configuration, so that
// we do not store an entity type that cannot be enabled or disabled.
if ($enabled && (!isset($field_definitions['path']) || $field_definitions['path']
->getProvider() === 'pathauto')) {
$enabled_entity_types[] = $entity_type_id;
}
}
$value = $enabled_entity_types;
}
elseif ($key == 'safe_tokens') {
$value = array_filter(array_map('trim', explode(',', $value)));
}
$config
->set($key, $value);
}
$config
->save();
parent::submitForm($form, $form_state);
}