You are here

public function SkipForm::submitForm in Notify 8

Same name and namespace in other branches
  1. 2.0.x src/Form/SkipForm.php \Drupal\notify\Form\SkipForm::submitForm()
  2. 1.0.x src/Form/SkipForm.php \Drupal\notify\Form\SkipForm::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/SkipForm.php, line 195

Class

SkipForm
Defines a form that configures forms module settings.

Namespace

Drupal\notify\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $form_values = $form_state
    ->getCompleteForm();
  $nodes = [];
  $comts = [];
  if (isset($values['entities']) && $values['entities']) {
    foreach ($values['entities'] as $dist => $ii) {
      if ($ii['dist']) {
        $nid = $form_values['entities'][$dist]['nid']['#markup'];
        $cid = $form_values['entities'][$dist]['cid']['#markup'];
        if ('-' == $cid) {
          array_push($nodes, (int) $nid);
        }
        else {
          array_push($comts, (int) $cid);
        }
      }
    }
    $this
      ->config('notify.settings')
      ->set('notify_skip_nodes', $nodes)
      ->set('notify_skip_comments', $comts)
      ->save();
  }
  $this->messenger
    ->addMessage($this
    ->t('Skip flags saved.'));
}