Mercurial > hg > cmmr2012-drupal-site
comparison vendor/chi-teck/drupal-code-generator/templates/d8/plugin/entity-reference-selection.twig @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\{{ machine_name }}\Plugin\EntityReferenceSelection; | |
4 | |
5 {% sort %} | |
6 {% if configurable %} | |
7 use Drupal\Core\Form\FormStateInterface; | |
8 {% endif %} | |
9 use {{ base_class_full }}; | |
10 {% endsort %} | |
11 | |
12 /** | |
13 * Plugin description. | |
14 * | |
15 * @EntityReferenceSelection( | |
16 * id = "{{ plugin_id }}", | |
17 * label = @Translation("{{ plugin_label }}"), | |
18 * group = "{{ plugin_id }}", | |
19 * entity_types = {"{{ entity_type }}"}, | |
20 * weight = 0 | |
21 * ) | |
22 */ | |
23 class {{ class }} extends {{ base_class }} { | |
24 | |
25 {% if configurable %} | |
26 /** | |
27 * {@inheritdoc} | |
28 */ | |
29 public function defaultConfiguration() { | |
30 | |
31 $default_configuration = [ | |
32 'foo' => 'bar', | |
33 ]; | |
34 | |
35 return $default_configuration + parent::defaultConfiguration(); | |
36 } | |
37 | |
38 /** | |
39 * {@inheritdoc} | |
40 */ | |
41 public function buildConfigurationForm(array $form, FormStateInterface $form_state) { | |
42 $form = parent::buildConfigurationForm($form, $form_state); | |
43 | |
44 $form['foo'] = [ | |
45 '#type' => 'textfield', | |
46 '#title' => $this->t('Foo'), | |
47 '#default_value' => $this->configuration['foo'], | |
48 ]; | |
49 | |
50 return $form; | |
51 } | |
52 | |
53 {% endif %} | |
54 /** | |
55 * {@inheritdoc} | |
56 */ | |
57 protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { | |
58 $query = parent::buildEntityQuery($match, $match_operator); | |
59 | |
60 // @DCG | |
61 // Here you can apply addition conditions, sorting, etc to the query. | |
62 // Also see self::entityQueryAlter(). | |
63 $query->condition('field_example', 123); | |
64 | |
65 return $query; | |
66 } | |
67 | |
68 } |