public function UnpublishedNodesRedirectSettingsForm::submitForm in Unpublished Nodes Redirect 2.x
Same name and namespace in other branches
- 8 src/Form/UnpublishedNodesRedirectSettingsForm.php \Drupal\unpublished_nodes_redirect\Form\UnpublishedNodesRedirectSettingsForm::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/ UnpublishedNodesRedirectSettingsForm.php, line 106
Class
- UnpublishedNodesRedirectSettingsForm
- Configure example settings for this site.
Namespace
Drupal\unpublished_nodes_redirect\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('unpublished_nodes_redirect.settings');
$content_types = Utils::getNodeTypes();
foreach ($content_types as $key => $type_name) {
// Validate whether the provided redirect paths are all internal.
$element_name = Utils::getNodeTypeKey($type_name);
$submitted_redirect_path = $form_state
->getValue($element_name);
$config
->set($element_name, $submitted_redirect_path);
// If a path is provided, make sure a response code is selected.
$element_name = Utils::getResponseCodeKey($type_name);
$submitted_response_code = $form_state
->getValue($element_name);
$config
->set($element_name, $submitted_response_code);
}
$config
->save();
parent::submitForm($form, $form_state);
}