1 {% extends "base/class.php.twig" %}
4 \Drupal\{{module}}\Plugin\views\field\{{class_name}}.
7 {% block namespace_class %}
8 namespace Drupal\{{module}}\Plugin\views\field;
12 use Drupal\Core\Form\FormStateInterface;
13 use Drupal\Component\Utility\Random;
14 use Drupal\views\Plugin\views\field\FieldPluginBase;
15 use Drupal\views\ResultRow;
18 {% block class_declaration %}
20 * A handler to provide a field that is completely custom by the administrator.
22 * @ingroup views_field_handlers
24 * @ViewsField("{{ class_machine_name }}")
26 class {{ class_name }} extends FieldPluginBase {% endblock %}
27 {% block class_methods %}
31 public function usesGroupBy() {
38 public function query() {
39 // Do nothing -- to override the parent query.
45 protected function defineOptions() {
46 $options = parent::defineOptions();
48 $options['hide_alter_empty'] = ['default' => FALSE];
55 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
56 parent::buildOptionsForm($form, $form_state);
62 public function render(ResultRow $values) {
63 // Return a random text, here you can include your custom logic.
64 // Include any namespace required to call the method required to generate
65 // the desired output.
66 $random = new Random();
67 return $random->name();