You are here

public function EventDateStringField::query in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/EventDateStringField.php \Drupal\rng\Plugin\views\field\EventDateStringField::query()

Called to add the field to a query.

Overrides FieldPluginBase::query

File

src/Plugin/views/field/EventDateStringField.php, line 133

Class

EventDateStringField
A handler to provide a field that is completely custom by the administrator.

Namespace

Drupal\rng\Plugin\views\field

Code

public function query() {
  return parent::query();
  $alias = 'date_table_min';
  $subquery = $this->database
    ->select($this->table, $alias);
  $subquery
    ->addField($alias, 'entity_id');
  $subquery
    ->addExpression('MIN(' . $alias . '.' . $this->realField . ')', 'min_date');
  $subquery
    ->groupBy($alias . '.entity_id');
  $join_table = $this->options['entity_type'] . '_field_data';
  $id_field = $this->entityTypeManager
    ->getDefinition($this->options['entity_type'])
    ->getKey('id');
  $definition = [
    'table formula' => $subquery,
    'field' => 'entity_id',
    'left_table' => $join_table,
    'left_field' => $id_field,
    'adjust' => TRUE,
  ];
  $join = $this->joinManager
    ->createInstance('standard', $definition);
  $this->query
    ->addRelationship('event_min_date', $join, $join_table);
}