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 ->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} 34