You are here

public function TwitterAccountsDeleteForm::submitForm in Tweet Feed 4.x

Same name and namespace in other branches
  1. 8.3 src/Form/TwitterAccountsDeleteForm.php \Drupal\tweet_feed\Form\TwitterAccountsDeleteForm::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 FormInterface::submitForm

File

src/Form/TwitterAccountsDeleteForm.php, line 37

Class

TwitterAccountsDeleteForm
Confirmation of Twitter API deletion.

Namespace

Drupal\tweet_feed\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = \Drupal::service('config.factory')
    ->getEditable('tweet_feed.twitter_accounts');
  $accounts = $config
    ->get('accounts');
  unset($accounts[$this->account_machine_name]);
  $config
    ->set('accounts', $accounts)
    ->save();
  \Drupal::messenger()
    ->addStatus($this
    ->t('The Twitter API account %account was deleted.', [
    '%account' => $this->account_machine_name,
  ]));
  $form_state
    ->setRedirect('tweet_feed.twitter_accounts');
  return;
}