Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / node / src / Form / NodeTypeDeleteConfirm.php
1 <?php
2
3 namespace Drupal\node\Form;
4
5 use Drupal\Core\Entity\EntityDeleteForm;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Provides a form for content type deletion.
10  *
11  * @internal
12  */
13 class 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       ->condition('type', $this->entity->id())
21       ->count()
22       ->execute();
23     if ($num_nodes) {
24       $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>';
25       $form['#title'] = $this->getQuestion();
26       $form['description'] = ['#markup' => $caption];
27       return $form;
28     }
29
30     return parent::buildForm($form, $form_state);
31   }
32
33 }