Security update for Core, with self-updated composer
[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\Core\Database\Query\Condition;
6 use Drupal\views\Plugin\views\filter\FilterPluginBase;
7
8 /**
9  * Filter handler to accept a user id to check for nodes that user posted or
10  * commented on.
11  *
12  * @ingroup views_filter_handlers
13  *
14  * @ViewsFilter("comment_user_uid")
15  */
16 class UserUid extends FilterPluginBase {
17
18   public function query() {
19     $this->ensureMyTable();
20
21     $subselect = db_select('comment_field_data', 'c');
22     $subselect->addField('c', 'cid');
23     $subselect->condition('c.uid', $this->value, $this->operator);
24
25     $entity_id = $this->definition['entity_id'];
26     $entity_type = $this->definition['entity_type'];
27     $subselect->where("c.entity_id = $this->tableAlias.$entity_id");
28     $subselect->condition('c.entity_type', $entity_type);
29
30     $condition = (new Condition('OR'))
31       ->condition("$this->tableAlias.uid", $this->value, $this->operator)
32       ->exists($subselect);
33
34     $this->query->addWhere($this->options['group'], $condition);
35   }
36
37 }