You are here

public function ActivityContactRecord::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 NumericFilter::query

File

src/Plugin/views/filter/ActivityContactRecord.php, line 39

Class

ActivityContactRecord
Filter handler for activity source contact.

Namespace

Drupal\civicrm_entity\Plugin\views\filter

Code

public function query() {
  $this
    ->ensureMyTable();
  $civicrm_activity_contact_table = 'civicrm_activity_contact';
  $configuration = [
    'table' => $civicrm_activity_contact_table,
    'field' => 'activity_id',
    'left_table' => $this->tableAlias,
    'left_field' => 'id',
    'operator' => '=',
  ];
  $join = Views::pluginManager('join')
    ->createInstance('standard', $configuration);
  $civicrm_activity_contact_table_alias = $this->query
    ->addRelationship($civicrm_activity_contact_table, $join, $this->tableAlias);
  $field = "{$civicrm_activity_contact_table_alias}.contact_id";
  $info = $this
    ->operators();
  if (!empty($info[$this->operator]['method']) && $this->recordTypeMapping[$this->realField]) {
    $condition = new Condition('AND');
    $condition
      ->condition($field, $this->value['value'], $this->operator);
    $condition
      ->condition("{$civicrm_activity_contact_table_alias}.record_type_id", $this->recordTypeMapping[$this->realField]);
    $this->query
      ->addWhere($this->options['group'], $condition);
  }
}