UserUid.php

Same filename in this branch
  1. 8.9.x core/modules/tracker/src/Plugin/views/filter/UserUid.php
  2. 8.9.x core/modules/tracker/src/Plugin/views/argument/UserUid.php
  3. 8.9.x core/modules/comment/src/Plugin/views/argument/UserUid.php
Same filename in other branches
  1. 9 core/modules/tracker/src/Plugin/views/filter/UserUid.php
  2. 9 core/modules/tracker/src/Plugin/views/argument/UserUid.php
  3. 9 core/modules/comment/src/Plugin/views/filter/UserUid.php
  4. 9 core/modules/comment/src/Plugin/views/argument/UserUid.php
  5. 10 core/modules/tracker/src/Plugin/views/filter/UserUid.php
  6. 10 core/modules/tracker/src/Plugin/views/argument/UserUid.php
  7. 10 core/modules/comment/src/Plugin/views/filter/UserUid.php
  8. 10 core/modules/comment/src/Plugin/views/argument/UserUid.php
  9. 11.x core/modules/tracker/src/Plugin/views/filter/UserUid.php
  10. 11.x core/modules/tracker/src/Plugin/views/argument/UserUid.php
  11. 11.x core/modules/comment/src/Plugin/views/filter/UserUid.php
  12. 11.x core/modules/comment/src/Plugin/views/argument/UserUid.php

Namespace

Drupal\comment\Plugin\views\filter

File

core/modules/comment/src/Plugin/views/filter/UserUid.php

View source
<?php

namespace Drupal\comment\Plugin\views\filter;

use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\Condition;
use Drupal\views\Plugin\views\filter\FilterPluginBase;

/**
 * Filter handler to accept a user id to check for nodes that user posted or
 * commented on.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("comment_user_uid")
 */
class UserUid extends FilterPluginBase {
    public function query() {
        $this->ensureMyTable();
        $subselect = Database::getConnection()->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 = (new Condition('OR'))->condition("{$this->tableAlias}.uid", $this->value, $this->operator)
            ->exists($subselect);
        $this->query
            ->addWhere($this->options['group'], $condition);
    }

}

Classes

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.