e4bea83fcb500b2087ea0ddac8506b162e202383
[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 class NodeTypeDeleteConfirm extends EntityDeleteForm {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function buildForm(array $form, FormStateInterface $form_state) {
17     $num_nodes = $this->entityTypeManager->getStorage('node')->getQuery()
18       ->condition('type', $this->entity->id())
19       ->count()
20       ->execute();
21     if ($num_nodes) {
22       $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>';
23       $form['#title'] = $this->getQuestion();
24       $form['description'] = ['#markup' => $caption];
25       return $form;
26     }
27
28     return parent::buildForm($form, $form_state);
29   }
30
31 }