3 namespace Drupal\block_content\Form;
5 use Drupal\Core\Entity\EntityDeleteForm;
6 use Drupal\Core\Form\FormStateInterface;
9 * Provides a confirmation form for deleting a custom block type entity.
11 class BlockContentTypeDeleteForm extends EntityDeleteForm {
16 public function buildForm(array $form, FormStateInterface $form_state) {
17 $blocks = $this->entityTypeManager->getStorage('block_content')->getQuery()
18 ->condition('type', $this->entity->id())
20 if (!empty($blocks)) {
21 $caption = '<p>' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', ['%label' => $this->entity->label()]) . '</p>';
22 $form['description'] = ['#markup' => $caption];
26 return parent::buildForm($form, $form_state);