Version 1
[yaffs-website] / web / modules / contrib / pathauto / src / Form / PatternEnableForm.php
diff --git a/web/modules/contrib/pathauto/src/Form/PatternEnableForm.php b/web/modules/contrib/pathauto/src/Form/PatternEnableForm.php
new file mode 100644 (file)
index 0000000..253ca31
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+namespace Drupal\pathauto\Form;
+
+use Drupal\Core\Entity\EntityConfirmFormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Url;
+
+/**
+ * Provides the pathauto pattern disable disable form.
+ */
+class PatternEnableForm extends EntityConfirmFormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getQuestion() {
+    return $this->t('Are you sure you want to enable the pattern %label?', array('%label' => $this->entity->label()));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCancelUrl() {
+    return new Url('entity.pathauto_pattern.collection');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfirmText() {
+    return $this->t('Enable');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDescription() {
+    return '';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    $this->entity->enable()->save();
+    drupal_set_message($this->t('Enabled pattern %label.', array('%label' => $this->entity->label())));
+
+    $form_state->setRedirectUrl($this->getCancelUrl());
+  }
+
+}