select2_bef.install in Select2 Boxes 8
Contains select2_bef.install.
File
modules/select2_bef/select2_bef.installView source
<?php
/**
* @file
* Contains select2_bef.install.
*/
/**
* Provide upgrade path for better_exposed_filters from 8.x-3.x to 8.x-4.x.
*/
function select2_bef_update_8001() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('views.view.') as $config_name) {
$config = $config_factory
->getEditable($config_name);
// Go through each display on each view.
$displays = $config
->get('display');
foreach ($displays as $display_name => $display) {
if (!empty($display['display_options']['exposed_form'])) {
$exposed_form = $display['display_options']['exposed_form'];
// Find BEF exposed forms.
if (isset($exposed_form['type']) && $exposed_form['type'] === 'bef' && isset($exposed_form['options']['bef']['filter'])) {
foreach ($exposed_form['options']['bef']['filter'] as $field_name => $configuration) {
if ($configuration['plugin_id'] === 'select2boxes_autocomplete_list' || $configuration['plugin_id'] === 'select2boxes_autocomplete_multi' || $configuration['plugin_id'] === 'select2boxes_autocomplete_single') {
$configuration['plugin_id'] = 'select2boxes';
$exposed_form['options']['bef']['filter'][$field_name] = $configuration;
}
}
// Update BEF settings.
$config
->set("display.{$display_name}.display_options.exposed_form.options.bef", $exposed_form['options']['bef']);
}
}
}
$config
->save(TRUE);
}
}
/**
* Make sure select2_bef upgrade path run after better_exposed_filters path.
*/
function select2_bef_update_dependencies() {
$dependencies = [];
$dependencies['select2_bef'][8001] = [
'better_exposed_filters' => 8001,
];
return $dependencies;
}
Functions
Name | Description |
---|---|
select2_bef_update_8001 | Provide upgrade path for better_exposed_filters from 8.x-3.x to 8.x-4.x. |
select2_bef_update_dependencies | Make sure select2_bef upgrade path run after better_exposed_filters path. |