Version 1
[yaffs-website] / vendor / drupal / console / templates / module / src / Plugin / Views / field / field.php.twig
diff --git a/vendor/drupal/console/templates/module/src/Plugin/Views/field/field.php.twig b/vendor/drupal/console/templates/module/src/Plugin/Views/field/field.php.twig
new file mode 100644 (file)
index 0000000..dba1baa
--- /dev/null
@@ -0,0 +1,69 @@
+{% extends "base/class.php.twig" %}
+
+{% block file_path %}
+\Drupal\{{module}}\Plugin\views\field\{{class_name}}.
+{% endblock %}
+
+{% block namespace_class %}
+namespace Drupal\{{module}}\Plugin\views\field;
+{% endblock %}
+
+{% block use_class %}
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Component\Utility\Random;
+use Drupal\views\Plugin\views\field\FieldPluginBase;
+use Drupal\views\ResultRow;
+{% endblock %}
+
+{% block class_declaration %}
+/**
+ * A handler to provide a field that is completely custom by the administrator.
+ *
+ * @ingroup views_field_handlers
+ *
+ * @ViewsField("{{ class_machine_name }}")
+ */
+class {{ class_name }} extends FieldPluginBase {% endblock %}
+{% block class_methods %}
+  /**
+   * {@inheritdoc}
+   */
+  public function usesGroupBy() {
+    return FALSE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function query() {
+    // Do nothing -- to override the parent query.
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function defineOptions() {
+    $options = parent::defineOptions();
+
+    $options['hide_alter_empty'] = ['default' => FALSE];
+    return $options;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+    parent::buildOptionsForm($form, $form_state);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function render(ResultRow $values) {
+    // Return a random text, here you can include your custom logic.
+    // Include any namespace required to call the method required to generate
+    // the desired output.
+    $random = new Random();
+    return $random->name();
+  }
+{% endblock %}