public function BatEventHandlerBlockingFilter::query in Booking and Availability Management Tools for Drupal 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 BooleanOperator::query
File
- modules/
bat_event/ src/ Plugin/ views/ filter/ BatEventHandlerBlockingFilter.php, line 51
Class
- BatEventHandlerBlockingFilter
- Plugin annotation @ViewsFilter("bat_event_handler_blocking_filter");
Namespace
Drupal\bat_event\Plugin\views\filterCode
public function query() {
$this
->ensureMyTable();
if ($this->value == 'not_blocking' || $this->value == 'blocking') {
$configuration = [
'table' => 'bat_event__event_state_reference',
'field' => 'entity_id',
'left_table' => 'event',
'left_field' => 'id',
'type' => 'left',
];
$state_reference_join = Views::pluginManager('join')
->createInstance('standard', $configuration);
$this->query
->addRelationship('bat_event__event_state_reference', $state_reference_join, 'event');
$configuration = [
'table' => 'states',
'field' => 'id',
'left_table' => 'bat_event__event_state_reference',
'left_field' => 'event_state_reference_target_id',
'type' => 'left',
];
$state_join = Views::pluginManager('join')
->createInstance('standard', $configuration);
$this->query
->addRelationship('states', $state_join, 'bat_event__event_state_reference');
if ($this->value == 'not_blocking') {
$this->query
->addWhere(1, 'states.blocking', '0', '=');
}
elseif ($this->value == 'blocking') {
$this->query
->addWhere(1, 'states.blocking', '1', '=');
}
}
}