You are here

public function ContactReference::query in CiviCRM Entity 8.3

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides StringFilter::query

File

src/Plugin/views/filter/ContactReference.php, line 61

Class

ContactReference
An "In" handler to include CiviCRM API.

Namespace

Drupal\civicrm_entity\Plugin\views\filter

Code

public function query() {
  $this
    ->ensureMyTable();
  $civicrm_contact_table = 'civicrm_contact';
  $configuration = [
    'table' => $civicrm_contact_table,
    'field' => 'id',
    'left_table' => $this->tableAlias,
    'left_field' => $this->realField,
    'operator' => '=',
  ];
  $join = Views::pluginManager('join')
    ->createInstance('standard', $configuration);
  $civicrm_contact_table_alias = $this->query
    ->addRelationship($civicrm_contact_table, $join, $this->tableAlias);
  $field = "{$civicrm_contact_table_alias}.sort_name";
  $info = $this
    ->operators();
  if (!empty($info[$this->operator]['method'])) {
    $this
      ->{$info[$this->operator]['method']}($field);
  }
}