public function OpignoGroupMembershipBoolean::query in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 src/Plugin/views/filter/OpignoGroupMembershipBoolean.php \Drupal\opigno_learning_path\Plugin\views\filter\OpignoGroupMembershipBoolean::query()
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 BooleanOperator::query
File
- src/
Plugin/ views/ filter/ OpignoGroupMembershipBoolean.php, line 66
Class
- OpignoGroupMembershipBoolean
- Filter handler to show trainings filter.
Namespace
Drupal\opigno_learning_path\Plugin\views\filterCode
public function query() {
$this
->ensureMyTable();
// Get current user and take filter value.
$user = \Drupal::currentUser();
$value = $this->value;
if ($value) {
// Add condition to select only items with membership.
$this->query
->addWhere($this->options['group'], 'group_content_field_data_groups_field_data.entity_id', $user
->id(), '=');
}
}