You are here

public function LingotekProfileDeleteForm::submitForm in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  2. 8.2 src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  3. 4.0.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  4. 3.0.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  5. 3.1.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  6. 3.2.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  7. 3.3.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  8. 3.5.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  9. 3.6.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  10. 3.7.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  11. 3.8.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()

Overrides EntityDeleteFormTrait::submitForm

File

src/Form/LingotekProfileDeleteForm.php, line 60

Class

LingotekProfileDeleteForm
Provides a form for lingotek profiles deletion.

Namespace

Drupal\lingotek\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $profile = $this
    ->getEntity();
  $usages = $this->profileUsage
    ->isUsedByContent($profile) | $this->profileUsage
    ->isUsedByConfig($profile) | $this->profileUsage
    ->isUsedByContentSettings($profile);
  if (!$usages) {
    $profile
      ->delete();
    $this
      ->messenger()
      ->addStatus($this
      ->t('The lingotek profile %profile has been deleted.', [
      '%profile' => $profile
        ->label(),
    ]));
  }
  else {
    $this
      ->messenger()
      ->addError($this
      ->t('The Lingotek profile %profile is being used so cannot be deleted.', [
      '%profile' => $profile
        ->label(),
    ]));
  }
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}