adee320d4403fb89b5aba43b908d01094bed6f00
[yaffs-website] / web / core / modules / comment / src / Plugin / views / filter / UserUid.php
1 <?php
2
3 namespace Drupal\comment\Plugin\views\filter;
4
5 use Drupal\views\Plugin\views\filter\FilterPluginBase;
6
7 /**
8  * Filter handler to accept a user id to check for nodes that user posted or
9  * commented on.
10  *
11  * @ingroup views_filter_handlers
12  *
13  * @ViewsFilter("comment_user_uid")
14  */
15 class UserUid extends FilterPluginBase {
16
17   public function query() {
18     $this->ensureMyTable();
19
20     $subselect = db_select('comment_field_data', 'c');
21     $subselect->addField('c', 'cid');
22     $subselect->condition('c.uid', $this->value, $this->operator);
23
24     $entity_id = $this->definition['entity_id'];
25     $entity_type = $this->definition['entity_type'];
26     $subselect->where("c.entity_id = $this->tableAlias.$entity_id");
27     $subselect->condition('c.entity_type', $entity_type);
28
29     $condition = db_or()
30       ->condition("$this->tableAlias.uid", $this->value, $this->operator)
31       ->exists($subselect);
32
33     $this->query->addWhere($this->options['group'], $condition);
34   }
35
36 }