public static function FilterWidgetBase::isApplicable in Better Exposed Filters 8.4
Same name and namespace in other branches
- 8.5 src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php \Drupal\better_exposed_filters\Plugin\better_exposed_filters\filter\FilterWidgetBase::isApplicable()
Verify this plugin can be used on the form element.
Parameters
mixed $handler: The handler type we are altering (e.g. filter, pager, sort).
array $options: The options for this handler.
Return value
bool If this plugin can be used.
Overrides BetterExposedFiltersWidgetInterface::isApplicable
1 call to FilterWidgetBase::isApplicable()
- Hidden::isApplicable in src/
Plugin/ better_exposed_filters/ filter/ Hidden.php - Verify this plugin can be used on the form element.
5 methods override FilterWidgetBase::isApplicable()
- DatePickers::isApplicable in src/
Plugin/ better_exposed_filters/ filter/ DatePickers.php - Verify this plugin can be used on the form element.
- DefaultWidget::isApplicable in src/
Plugin/ better_exposed_filters/ filter/ DefaultWidget.php - Verify this plugin can be used on the form element.
- Hidden::isApplicable in src/
Plugin/ better_exposed_filters/ filter/ Hidden.php - Verify this plugin can be used on the form element.
- Single::isApplicable in src/
Plugin/ better_exposed_filters/ filter/ Single.php - Verify this plugin can be used on the form element.
- Sliders::isApplicable in src/
Plugin/ better_exposed_filters/ filter/ Sliders.php - Verify this plugin can be used on the form element.
File
- src/
Plugin/ better_exposed_filters/ filter/ FilterWidgetBase.php, line 24
Class
- FilterWidgetBase
- Base class for Better exposed filters widget plugins.
Namespace
Drupal\better_exposed_filters\Plugin\better_exposed_filters\filterCode
public static function isApplicable($filter = NULL, array $filter_options = []) {
/** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
$is_applicable = FALSE;
// Sanity check to ensure we have a filter to work with.
if (!isset($filter)) {
return $is_applicable;
}
// Check various filter types and determine what options are available.
if (is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\StringFilter') || is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
if (in_array($filter->operator, [
'in',
'or',
'and',
'not',
])) {
$is_applicable = TRUE;
}
if (in_array($filter->operator, [
'empty',
'not empty',
])) {
$is_applicable = TRUE;
}
}
if (is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\BooleanOperator')) {
$is_applicable = TRUE;
}
if (is_a($filter, 'Drupal\\taxonomy\\Plugin\\views\\filter\\TaxonomyIndexTid')) {
// Autocomplete and dropdown taxonomy filter are both instances of
// TaxonomyIndexTid, but we can't show BEF options for the autocomplete
// widget.
if ($filter_options['type'] == 'select') {
$is_applicable = TRUE;
}
}
if ($filter
->isAGroup()) {
$is_applicable = TRUE;
}
if (is_a($filter, 'Drupal\\search_api\\Plugin\\views\\filter\\SearchApiFulltext')) {
$is_applicable = TRUE;
}
return $is_applicable;
}