You are here

public function LingotekProfileDeleteForm::submitForm in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  2. 4.0.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  3. 3.0.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  4. 3.1.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  5. 3.2.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  6. 3.3.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
  7. 3.4.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 65
Contains \Drupal\lingotek\Form\LingotekProfileDeleteForm.

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();
    drupal_set_message($this
      ->t('The lingotek profile %profile has been deleted.', [
      '%profile' => $profile
        ->label(),
    ]));
  }
  else {
    drupal_set_message($this
      ->t('The Lingotek profile %profile is being used so cannot be deleted.', [
      '%profile' => $profile
        ->label(),
    ]), 'error');
  }
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}