public function SocialDate::acceptExposedInput in Open Social 8.7
Same name and namespace in other branches
- 8.9 modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
- 8.6 modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
- 8.8 modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
- 10.3.x modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
- 10.0.x modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
- 10.1.x modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
- 10.2.x modules/social_features/social_search/src/Plugin/views/filter/SocialDate.php \Drupal\social_search\Plugin\views\filter\SocialDate::acceptExposedInput()
Do some minor translation of the exposed input
Overrides SearchApiDate::acceptExposedInput
File
- modules/
social_features/ social_search/ src/ Plugin/ views/ filter/ SocialDate.php, line 20
Class
- SocialDate
- Defines a filter for filtering on dates.
Namespace
Drupal\social_search\Plugin\views\filterCode
public function acceptExposedInput($input) {
if (empty($this->options['exposed'])) {
return TRUE;
}
// Don't filter if value(s) are empty.
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
$operator = $input[$this->options['expose']['operator_id']];
}
else {
$operator = $this->operator;
}
// Custom override to ensure that when users
// filter on something different than the event type
// we also don't use an event field filter.
if (!empty($input['type']) && $input['type'] !== 'event') {
$input['field_event_date']['value'] = '';
$input['field_event_date']['max'] = '';
$input['field_event_date']['min'] = '';
}
// Fallback for exposed operator.
$operatorfromurl = NULL;
if ($operator === NULL && $this->realField === 'created') {
// Check if we have it in the query.
$operatorfromurl = \Drupal::request()->query
->get('created_op');
if (!empty($operatorfromurl)) {
$this->operator = $operatorfromurl;
$input['created_op'] = $operatorfromurl;
$this->view->exposed_raw_input = $this->view
->getExposedInput();
}
}
if ($operator === NULL && $operatorfromurl === NULL) {
return FALSE;
}
$return = parent::acceptExposedInput($input);
if (!$return) {
// Override for the "(not) empty" operators.
$operators = $this
->operators();
if ($operators[$this->operator]['values'] === 0) {
return TRUE;
}
}
return $return;
}