3 namespace Drupal\comment\Plugin\views\filter;
5 use Drupal\Core\Database\Query\Condition;
6 use Drupal\views\Plugin\views\filter\FilterPluginBase;
9 * Filter handler to accept a user id to check for nodes that user posted or
12 * @ingroup views_filter_handlers
14 * @ViewsFilter("comment_user_uid")
16 class UserUid extends FilterPluginBase {
18 public function query() {
19 $this->ensureMyTable();
21 $subselect = db_select('comment_field_data', 'c');
22 $subselect->addField('c', 'cid');
23 $subselect->condition('c.uid', $this->value, $this->operator);
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);
30 $condition = (new Condition('OR'))
31 ->condition("$this->tableAlias.uid", $this->value, $this->operator)
34 $this->query->addWhere($this->options['group'], $condition);