Version 1
[yaffs-website] / web / modules / contrib / metatag / src / Form / MetatagDefaultsDeleteForm.php
diff --git a/web/modules/contrib/metatag/src/Form/MetatagDefaultsDeleteForm.php b/web/modules/contrib/metatag/src/Form/MetatagDefaultsDeleteForm.php
new file mode 100644 (file)
index 0000000..73589a0
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\metatag\Form;
+
+use Drupal\Core\Entity\EntityConfirmFormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Url;
+
+/**
+ * Builds the form to delete Metatag defaults entities.
+ */
+class MetatagDefaultsDeleteForm extends EntityConfirmFormBase {
+  /**
+   * {@inheritdoc}
+   */
+  public function getQuestion() {
+    return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCancelUrl() {
+    return new Url('entity.metatag_defaults.collection');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfirmText() {
+    return $this->t('Delete');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    $this->entity->delete();
+
+    drupal_set_message(
+      $this->t('Deleted @label defaults.',
+        [
+          '@label' => $this->entity->label()
+        ]
+        )
+    );
+
+    $form_state->setRedirectUrl($this->getCancelUrl());
+  }
+
+}