You are here

public function SupportTicketTypeDeleteConfirm::buildForm in Support Ticketing System 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 EntityDeleteForm::buildForm

File

modules/support_ticket/src/Form/SupportTicketTypeDeleteConfirm.php, line 49
Contains \Drupal\support_ticket\Form\SupportTypeDeleteConfirm.

Class

SupportTicketTypeDeleteConfirm
Provides a form for support ticket type deletion.

Namespace

Drupal\support_ticket\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $num_support_tickets = $this->queryFactory
    ->get('support_ticket')
    ->condition('support_ticket_type', $this->entity
    ->id())
    ->count()
    ->execute();
  if ($num_support_tickets) {
    $caption = '<p>' . $this
      ->formatPlural($num_support_tickets, '%type is used by 1 ticket on your site. You can not remove this support ticket type until you have removed all of the %type tickets.', '%type is used by @count tickets on your site. You may not remove %type until you have removed all of the %type tickets.', array(
      '%type' => $this->entity
        ->label(),
    )) . '</p>';
    $form['#title'] = $this
      ->getQuestion();
    $form['description'] = array(
      '#markup' => $caption,
    );
    return $form;
  }
  return parent::buildForm($form, $form_state);
}