function FilterPluginBase::hasValidGroupedValue
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::hasValidGroupedValue()
- 8.9.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::hasValidGroupedValue()
- 11.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::hasValidGroupedValue()
Determines if the given grouped filter entry has a valid value.
Parameters
array $group: A group entry as defined by buildGroupForm().
Return value
bool
1 call to FilterPluginBase::hasValidGroupedValue()
- FilterPluginBase::buildGroupValidate in core/
modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php - Validate the build group options form.
1 method overrides FilterPluginBase::hasValidGroupedValue()
- Date::hasValidGroupedValue in core/
modules/ views/ src/ Plugin/ views/ filter/ Date.php - Determines if the given grouped filter entry has a valid value.
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php, line 722
Class
- FilterPluginBase
- Base class for Views filters handler plugins.
Namespace
Drupal\views\Plugin\views\filterCode
protected function hasValidGroupedValue(array $group) {
if (!method_exists($this, 'operators')) {
throw new \LogicException(get_class($this) . '::operators() not implemented');
}
$operators = $this->operators();
if ($operators[$group['operator']]['values'] == 0) {
// Some filters, such as "is empty," do not require a value to be
// specified in order to be valid entries.
return TRUE;
}
else {
if (is_string($group['value'])) {
return trim($group['value']) != '';
}
elseif (is_array($group['value'])) {
// Some filters allow multiple options to be selected (for example, node
// types). Ensure at least the minimum number of values is present for
// this entry to be considered valid.
$min_values = $operators[$group['operator']]['values'];
$actual_values = count(array_filter($group['value'], [
static::class,
'arrayFilterZero',
]));
return $actual_values >= $min_values;
}
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.