Version 1
[yaffs-website] / vendor / drupal / console / templates / module / src / Plugin / Views / field / field.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{module}}\Plugin\views\field\{{class_name}}.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{module}}\Plugin\views\field;
9 {% endblock %}
10
11 {% block use_class %}
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;
16 {% endblock %}
17
18 {% block class_declaration %}
19 /**
20  * A handler to provide a field that is completely custom by the administrator.
21  *
22  * @ingroup views_field_handlers
23  *
24  * @ViewsField("{{ class_machine_name }}")
25  */
26 class {{ class_name }} extends FieldPluginBase {% endblock %}
27 {% block class_methods %}
28   /**
29    * {@inheritdoc}
30    */
31   public function usesGroupBy() {
32     return FALSE;
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function query() {
39     // Do nothing -- to override the parent query.
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   protected function defineOptions() {
46     $options = parent::defineOptions();
47
48     $options['hide_alter_empty'] = ['default' => FALSE];
49     return $options;
50   }
51
52   /**
53    * {@inheritdoc}
54    */
55   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
56     parent::buildOptionsForm($form, $form_state);
57   }
58
59   /**
60    * {@inheritdoc}
61    */
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();
68   }
69 {% endblock %}