Skip to content
Snippets Groups Projects
Commit d4866a21 authored by davisben's avatar davisben
Browse files

Issue #3292085: Mail Group Type can be deleted while still in use

parent 970fa59b
No related branches found
No related tags found
1 merge request!12Issue #3292085: Mail Group Type can be deleted while still in use
......@@ -32,6 +32,37 @@ class MailGroupTypeDeleteForm extends EntityConfirmFormBase {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$count = $this->entityTypeManager
->getStorage('mailgroup')
->getQuery()
->accessCheck(FALSE)
->condition('type', $this->entity->id())
->count()
->execute();
if ($count) {
$message = $this->formatPlural(
$count,
'There is 1 group of the type %type. You can not remove this group type until you have removed all of the %type groups.',
'There are @count groups of the type %type. You can not remove this group type until you have removed all of the %type groups.',
['%type' => $this->entity->label()]
);
$form['#title'] = $this->getQuestion();
$form['description'] = [
'#markup' => '<p>' . $message . '</p>',
];
return $form;
}
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment