Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / plugin / filter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/filter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/filter.twig
new file mode 100644 (file)
index 0000000..d080e2b
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+namespace Drupal\{{ machine_name }}\Plugin\Filter;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\filter\FilterProcessResult;
+use Drupal\filter\Plugin\FilterBase;
+
+/**
+ * Provides a '{{ plugin_label }}' filter.
+ *
+ * @Filter(
+ *   id = "{{ plugin_id }}",
+ *   title = @Translation("{{ plugin_label }}"),
+ *   type = Drupal\filter\Plugin\FilterInterface::{{ filter_type }},
+ *   settings = {
+ *     "example" = "foo",
+ *   },
+ *   weight = -10
+ * )
+ */
+class {{ class }} extends FilterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $form['example'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Example'),
+      '#default_value' => $this->settings['example'],
+      '#description' => $this->t('Description of the setting.'),
+    ];
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function process($text, $langcode) {
+    // @DCG Process text here.
+    $example = $this->settings['example'];
+    $text = str_replace($example, "<b>$example</b>", $text);
+    return new FilterProcessResult($text);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function tips($long = FALSE) {
+    return $this->t('Some filter tips here.');
+  }
+
+}