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