You are here

public function AppApiKeyDeleteFormBase::submitForm in Apigee Edge 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/AppApiKeyDeleteFormBase.php, line 56

Class

AppApiKeyDeleteFormBase
Provides delete confirmation base form for app API key.

Namespace

Drupal\apigee_edge\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $args = [
    '%key' => $this->consumerKey,
    '@app' => $this->app
      ->label(),
  ];
  try {
    $this
      ->appCredentialController($this->app
      ->getAppOwner(), $this->app
      ->getName())
      ->delete($this->consumerKey);
    Cache::invalidateTags($this->app
      ->getCacheTags());
    $this
      ->messenger()
      ->addStatus($this
      ->t('API key %key deleted from @app.', $args));
  } catch (\Exception $exception) {
    $this
      ->messenger()
      ->addError($this
      ->t('Failed to delete API key %key from @app.', $args));
  }
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}