Skip to content
Snippets Groups Projects

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

Merged davisben requested to merge issue/mailgroup-3292085:3292085-mail-group-type into 2.1.x
1 file
+ 31
0
Compare changes
  • Side-by-side
  • Inline
@@ -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}
*/
Loading