public function LingotekProfileDeleteForm::submitForm in Lingotek Translation 8.2
Same name and namespace in other branches
- 8 src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 4.0.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.0.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.1.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.2.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.3.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.4.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.5.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.6.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 3.7.x src/Form/LingotekProfileDeleteForm.php \Drupal\lingotek\Form\LingotekProfileDeleteForm::submitForm()
- 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\FormCode
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());
}