Version 1
[yaffs-website] / web / core / modules / block_content / src / Form / BlockContentDeleteForm.php
diff --git a/web/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/web/core/modules/block_content/src/Form/BlockContentDeleteForm.php
new file mode 100644 (file)
index 0000000..035ec4c
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\block_content\Form;
+
+use Drupal\Core\Entity\ContentEntityDeleteForm;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Provides a confirmation form for deleting a custom block entity.
+ */
+class BlockContentDeleteForm extends ContentEntityDeleteForm {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $instances = $this->entity->getInstances();
+
+    $form['message'] = [
+      '#markup' => $this->formatPlural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'),
+      '#access' => !empty($instances),
+    ];
+
+    return parent::buildForm($form, $form_state);
+  }
+
+}