Skip to content
Snippets Groups Projects
Commit bb744297 authored by Daniel Cothran's avatar Daniel Cothran
Browse files

Issue #3376644: Enable use of more than one filter plugin

parent 0fef7071
No related branches found
No related tags found
1 merge request!4Update views_fields_on_off.module
......@@ -13,13 +13,24 @@ use Drupal\views\Views;
*/
function views_fields_on_off_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
// If using the Views filter rather than the Views field.
$filter_plugin = $view->getHandler($display_id, 'filter', 'views_fields_on_off_form');
if (!empty($filter_plugin) && empty($filter_plugin['bypass_hook_views_pre_view'])) {
_views_fields_on_off_process_filter($view, $filter_plugin);
$filter_handlers = $view->getHandlers('filter', $view->current_display);
if (!empty($filter_handlers)) {
foreach ($filter_handlers as $filter_plugin) {
$plugin_id = $filter_plugin['plugin_id'] ?? '';
if ($plugin_id === 'views_fields_on_off_form' && empty($filter_plugin['bypass_hook_views_pre_view'])) {
_views_fields_on_off_process_filter($view, $filter_plugin);
}
}
}
// Using the field plugin.
else {
_views_fields_on_off_process_field($view, $display_id);
// If using the Views field.
$field_handlers = $view->getHandlers('field', $view->current_display);
if (!empty($field_handlers)) {
foreach ($field_handlers as $field_plugin) {
$plugin_id = $field_plugin['plugin_id'] ?? '';
if ($plugin_id === 'views_fields_on_off_form') {
_views_fields_on_off_process_field($view, $display_id);
}
}
}
}
......@@ -113,7 +124,7 @@ function _views_fields_on_off_process_field(ViewExecutable $view, $display_id) {
}
}
else {
if ((empty($selection) && !empty($field_option)) || (!in_array($field_option, $selection) && !empty($field_option))) {
if ((empty($selection) && !empty($field_option)) || (!empty($field_option) && !in_array($field_option, (array) $selection))) {
$fields[$field_option]['exclude'] = 1;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment