public function query()

in modules/quanthub_core/src/Plugin/views/filter/AllowedContentFilter.php [48:92]


  public function query() {
    $datasets = [];

    $this->ensureMyTable();
    if (getenv('WSO_IGNORE') !== 'TRUE') {
      $datasets = $this->allowedContentManager->getAllowedDatasetList();
    }

    $field = "$this->tableAlias.{$this->realField}_value";

    /** @var \Drupal\views\Plugin\views\query\Sql $query */
    $query = $this->query;

    // Added filter in view SQL for filtering according to user allowed content
    // in user data provided by xacml.
    if (!empty($datasets)) {
      if (count($datasets) > 1) {
        $or_conditions = $this->query->getConnection()->condition('OR');
        foreach ($datasets as $dataset) {
          if (str_ends_with($dataset, ')')) {
            $or_conditions->condition($field, $dataset);
          }
          else {
            $or_conditions->condition($field, $dataset . '%', 'LIKE');
          }
        }

        $query->addWhere($this->options['group'], $or_conditions);
      }
      elseif (count($datasets) == 1) {
        $dataset = reset($datasets);
        if (str_ends_with($dataset, ')')) {
          $query->addWhere($this->options['group'], $field);
        }
        else {
          $query->addWhere(
            $this->options['group'],
            $field,
            $dataset . '%',
            'LIKE'
          );
        }
      }
    }
  }