You are here

public function CropTypeDeleteForm::buildForm in Crop API 8.2

Same name and namespace in other branches
  1. 8 src/Form/CropTypeDeleteForm.php \Drupal\crop\Form\CropTypeDeleteForm::buildForm()

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/CropTypeDeleteForm.php, line 67

Class

CropTypeDeleteForm
Provides a form for crop type deletion.

Namespace

Drupal\crop\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $count = $this->entityTypeManager
    ->getStorage('crop')
    ->getQuery()
    ->condition('type', $this->entity
    ->id())
    ->count()
    ->execute();
  if ($count) {
    $form['#title'] = $this
      ->getQuestion();
    $form['description'] = [
      '#prefix' => '<p>',
      '#markup' => $this->translation
        ->formatPlural($count, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', [
        '%type' => $this->entity
          ->label(),
      ]),
      '#suffix' => '</p>',
    ];
    return $form;
  }
  return parent::buildForm($form, $form_state);
}