3 namespace Drupal\{{ machine_name }}\Plugin\EntityReferenceSelection;
7 use Drupal\Core\Form\FormStateInterface;
9 use {{ base_class_full }};
15 * @EntityReferenceSelection(
16 * id = "{{ plugin_id }}",
17 * label = @Translation("{{ plugin_label }}"),
18 * group = "{{ plugin_id }}",
19 * entity_types = {"{{ entity_type }}"},
23 class {{ class }} extends {{ base_class }} {
29 public function defaultConfiguration() {
31 $default_configuration = [
35 return $default_configuration + parent::defaultConfiguration();
41 public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
42 $form = parent::buildConfigurationForm($form, $form_state);
45 '#type' => 'textfield',
46 '#title' => $this->t('Foo'),
47 '#default_value' => $this->configuration['foo'],
57 protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
58 $query = parent::buildEntityQuery($match, $match_operator);
61 // Here you can apply addition conditions, sorting, etc to the query.
62 // Also see self::entityQueryAlter().
63 $query->condition('field_example', 123);