1<?php
2
3namespace Drupal\node\Form;
4
5use Drupal\Core\Entity\EntityDeleteForm;
6use Drupal\Core\Form\FormStateInterface;
7
8/**
9 * Provides a form for content type deletion.
10 *
11 * @internal
12 */
13class NodeTypeDeleteConfirm extends EntityDeleteForm {
14
15  /**
16   * {@inheritdoc}
17   */
18  public function buildForm(array $form, FormStateInterface $form_state) {
19    $num_nodes = $this->entityTypeManager->getStorage('node')->getQuery()
20      ->accessCheck(FALSE)
21      ->condition('type', $this->entity->id())
22      ->count()
23      ->execute();
24    if ($num_nodes) {
25      $caption = '<p>' . $this->formatPlural($num_nodes, '%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()]) . '</p>';
26      $form['#title'] = $this->getQuestion();
27      $form['description'] = ['#markup' => $caption];
28      return $form;
29    }
30
31    return parent::buildForm($form, $form_state);
32  }
33
34}
35