public function MessageTemplateDeleteConfirm::buildForm in Message 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EntityConfirmFormBase::buildForm
File
- src/
Form/ MessageTemplateDeleteConfirm.php, line 31
Class
- MessageTemplateDeleteConfirm
- Provides a form for message template deletion.
Namespace
Drupal\message\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Check if any messages are using this template.
$number_messages = $this->entityTypeManager
->getStorage('message')
->getQuery()
->condition('template', $this->entity
->id())
->count()
->execute();
if ($number_messages) {
$caption = '<p>' . $this
->formatPlural($number_messages, '%template is used by 1 message on your site. You cannot remove this message template until you have removed all of the %template messages.', '%template is used by @count messages on your site. You may not remove %template until you have removed all of the %template messages.', [
'%template' => $this->entity
->label(),
]) . '</p>';
$form['#title'] = $this
->getQuestion();
$form['description'] = [
'#markup' => $caption,
];
return $form;
}
return parent::buildForm($form, $form_state);
}