public function ProtectedPagesEditForm::submitForm in Protected Pages 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 FormInterface::submitForm
File
- src/
Form/ ProtectedPagesEditForm.php, line 185
Class
- ProtectedPagesEditForm
- Provides an edit protected page form.
Namespace
Drupal\protected_pages\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$page_data = [];
$password = $form_state
->getValue('password');
if (!empty($password)) {
$page_data['password'] = $this->password
->hash(Html::escape($password));
}
$page_data['path'] = Html::escape($form_state
->getValue('path'));
$this->protectedPagesStorage
->updateProtectedPage($page_data, $form_state
->getValue('pid'));
$this->messenger
->addMessage($this
->t('The protected page settings have been successfully saved.'));
drupal_flush_all_caches();
$form_state
->setRedirect('protected_pages_list');
}