You are here

public function UserUid::query in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/tracker/src/Plugin/views/filter/UserUid.php \Drupal\tracker\Plugin\views\filter\UserUid::query()
  2. 8 core/modules/tracker/src/Plugin/views/argument/UserUid.php \Drupal\tracker\Plugin\views\argument\UserUid::query()
  3. 8 core/modules/comment/src/Plugin/views/filter/UserUid.php \Drupal\comment\Plugin\views\filter\UserUid::query()
  4. 8 core/modules/comment/src/Plugin/views/argument/UserUid.php \Drupal\comment\Plugin\views\argument\UserUid::query()
Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Plugin/views/filter/UserUid.php \Drupal\comment\Plugin\views\filter\UserUid::query()

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 FilterPluginBase::query

File

core/modules/comment/src/Plugin/views/filter/UserUid.php, line 22
Contains \Drupal\comment\Plugin\views\filter\UserUid.

Class

UserUid
Filter handler to accept a user id to check for nodes that user posted or commented on.

Namespace

Drupal\comment\Plugin\views\filter

Code

public function query() {
  $this
    ->ensureMyTable();
  $subselect = db_select('comment_field_data', 'c');
  $subselect
    ->addField('c', 'cid');
  $subselect
    ->condition('c.uid', $this->value, $this->operator);
  $entity_id = $this->definition['entity_id'];
  $entity_type = $this->definition['entity_type'];
  $subselect
    ->where("c.entity_id = {$this->tableAlias}.{$entity_id}");
  $subselect
    ->condition('c.entity_type', $entity_type);
  $condition = db_or()
    ->condition("{$this->tableAlias}.uid", $this->value, $this->operator)
    ->exists($subselect);
  $this->query
    ->addWhere($this->options['group'], $condition);
}