public function CallbackForm::submitForm in Empty Page 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/ CallbackForm.php, line 82
Class
- CallbackForm
- Builds the form for callbacks add/edit form.
Namespace
Drupal\empty_page\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$new = FALSE;
$settings = $this
->config('empty_page.settings');
if (empty($this->cid)) {
$new = TRUE;
$id = $this
->config('empty_page.settings')
->get('new_id');
$callback['created'] = \Drupal::time()
->getRequestTime();
}
else {
$id = $this->cid;
$callback['created'] = $settings
->get('callback_' . $id)['created'];
}
$callback['cid'] = $id;
$callback['updated'] = \Drupal::time()
->getRequestTime();
$callback['path'] = $values['empty_page_callback_path'];
$callback['page_title'] = $values['empty_page_callback_page_title'];
$config = $this
->config('empty_page.settings')
->set('callback_' . $id, $callback);
$config = $new ? $config
->set('new_id', $id + 1) : $config;
$config
->save();
\Drupal::service('router.builder')
->rebuild();
$this
->messenger()
->addMessage($this
->t('Changes saved.'));
$form_state
->setRedirect('empty_page.administration');
}