public function MediaDirectory::acceptExposedInput in Media Directories 3.x
Same name and namespace in other branches
- 8 src/Plugin/views/filter/MediaDirectory.php \Drupal\media_directories\Plugin\views\filter\MediaDirectory::acceptExposedInput()
- 2.x src/Plugin/views/filter/MediaDirectory.php \Drupal\media_directories\Plugin\views\filter\MediaDirectory::acceptExposedInput()
Determines if the input from a filter should change the generated query.
Parameters
array $input: The exposed data for this view.
Return value
bool TRUE if the input for this filter should be included in the view query. FALSE otherwise.
Overrides InOperator::acceptExposedInput
File
- src/
Plugin/ views/ filter/ MediaDirectory.php, line 204
Class
- MediaDirectory
- Filter media by directory.
Namespace
Drupal\media_directories\Plugin\views\filterCode
public function acceptExposedInput($input) {
if (empty($this->options['exposed'])) {
return TRUE;
}
// We need to know the operator, which is normally set in
// \Drupal\views\Plugin\views\filter\FilterPluginBase::acceptExposedInput(),
// before we actually call the parent version of ourselves.
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
$this->operator = $input[$this->options['expose']['operator_id']];
}
// If view is an attachment and is inheriting exposed filters, then assume
// exposed input has already been validated.
if (!empty($this->view->is_attachment) && $this->view->display_handler
->usesExposed()) {
$this->validated_exposed_input = (array) $this->view->exposed_raw_input[$this->options['expose']['identifier']];
}
// If we're checking for EMPTY or NOT, we don't need any input, and we can
// say that our input conditions are met by just having the right operator.
if ($this->operator == 'empty' || $this->operator == 'not empty') {
return TRUE;
}
$rc = parent::acceptExposedInput($input);
$value = $input[$this->options['expose']['identifier']];
// Change default behaviour, we need to filter 'All' values.
if (!$rc && $value === MEDIA_DIRECTORY_ROOT) {
$rc = TRUE;
$this->validated_exposed_input = [
$value,
];
}
if ($rc) {
// If we have previously validated input, override.
if (isset($this->validated_exposed_input)) {
$this->value = $this->validated_exposed_input;
}
}
return $rc;
}