public function Selective::getValueOptions in Views Selective Filters 8
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.
This can use a guard to be used to reduce database hits as much as possible.
Return value
array|null The stored values from $this->valueOptions.
Overrides InOperator::getValueOptions
1 call to Selective::getValueOptions()
- Selective::valueForm in src/
Plugin/ views/ filter/ Selective.php - Options form subform for setting options.
File
- src/
Plugin/ views/ filter/ Selective.php, line 66
Class
- Selective
- Views filter handler for selective values.
Namespace
Drupal\views_selective_filters\Plugin\views\filterCode
public function getValueOptions() {
if (isset($this->valueOptions)) {
return $this->valueOptions;
}
$this->valueOptions = [];
// If $this->view->selective_oids means that the handler is being called
// inside the cloned view used to obtain the selective values and thus this
// is to prevent infinite recursive loop.
if (empty($this->view->selective_oids) && !empty($this->view->inited)) {
$this->valueOptions = $this
->getOids();
// TODO: Omit null values in result: they are improperly handled.
// When constructing the query.
$this->valueOptions = array_diff_key($this->valueOptions, [
'' => NULL,
]);
// Set a flag in the view so we know it is using selective filters.
$this->view->using_selective = TRUE;
}
else {
if (!empty($this->view->selective_oids)) {
$this->valueOptions = [];
}
else {
// This is a special case, if $this->valueOptions is not an array
// then parent::valueForm() will throw an exception, so,
// in our custom override no form is generated when $this->valueOptions
// is not an array. We only want this to happen in the administrative
// interface.
// unset($this->valueOptions);.
}
}
return $this->valueOptions;
}