public function RateFilter::query in Rate 8
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides NumericFilter::query
File
- src/
Plugin/ views/ filter/ RateFilter.php, line 53
Class
- RateFilter
- Simple filter to handle greater than/less than filters.
Namespace
Drupal\rate\Plugin\views\filterCode
public function query() {
$this
->ensureMyTable();
$id = $this->entityTypeManager
->getDefinition($this->tableAlias)
->get('entity_keys')['id'];
$configuration = [
'table' => 'votingapi_result',
'field' => 'entity_id',
'left_table' => $this->tableAlias . '._field_data',
'left_field' => $this->tableAlias . '.' . $id,
'operator' => '=',
];
$join = Views::pluginManager('join')
->createInstance('standard', $configuration);
$this->query
->addRelationship('vote', $join, $this->tableAlias . '._field_data');
$info = $this
->operators();
if (!empty($info[$this->operator]['method'])) {
$this->query
->addWhere('AND', 'vote.entity_type', $this->tableAlias);
$this->query
->addWhere('AND', 'vote.function', 'vote_average');
$this
->{$info[$this->operator]['method']}('vote.value');
}
}