You are here

public function LtiToolProviderConsumerDeleteForm::submitForm in LTI Tool Provider 2.x

Same name and namespace in other branches
  1. 8 src/Form/LtiToolProviderConsumerDeleteForm.php \Drupal\lti_tool_provider\Form\LtiToolProviderConsumerDeleteForm::submitForm()

Delete the entity and log the event. log() replaces the watchdog.

Overrides ContentEntityForm::submitForm

File

src/Form/LtiToolProviderConsumerDeleteForm.php, line 45

Class

LtiToolProviderConsumerDeleteForm
Form for deleting a lti_tool_provider_consumer entity.

Namespace

Drupal\lti_tool_provider\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $entity = $this
    ->getEntity();
  try {
    $entity
      ->delete();
    Drupal::logger('lti_tool_provider')
      ->notice('@type: deleted %title.', [
      '@type' => $this->entity
        ->bundle(),
      '%title' => $this->entity
        ->label(),
    ]);
  } catch (EntityStorageException $e) {
    Drupal::logger('lti_tool_provider')
      ->error('@type: error deleting %title.', [
      '@type' => $this->entity
        ->bundle(),
      '%title' => $this->entity
        ->label(),
    ]);
  }
  $form_state
    ->setRedirect('entity.lti_tool_provider_consumer.collection');
}