You are here

protected function Select2Boxes::addIncludeIconsOption in Select2 Boxes 8

Include flags icons.

Parameters

array &$form: Form array.

\Drupal\views\Plugin\views\filter\FilterPluginBase $filter: View filter object.

1 call to Select2Boxes::addIncludeIconsOption()
Select2Boxes::buildConfigurationForm in modules/select2_bef/src/Plugin/better_exposed_filters/filter/Select2Boxes.php

File

modules/select2_bef/src/Plugin/better_exposed_filters/filter/Select2Boxes.php, line 144

Class

Select2Boxes
Default widget implementation.

Namespace

Drupal\select2_bef\Plugin\better_exposed_filters\filter

Code

protected function addIncludeIconsOption(array &$form, FilterPluginBase $filter) {

  // Check if the field is of allowed type to include flags icons.
  $applicable_fields = [
    'Drupal\\views\\Plugin\\views\\filter\\LanguageFilter',
    'Drupal\\country\\Plugin\\views\\filter\\CountryItem',
    'Drupal\\address\\Plugin\\views\\filter\\Country',
  ];
  foreach ($applicable_fields as $field) {
    if (is_a($filter, $field)) {
      if (\Drupal::moduleHandler()
        ->moduleExists('flags')) {

        // Add a new option to the settings form.
        $form['advanced']['include_flags'] = [
          '#type' => 'checkbox',
          '#title' => $this
            ->t('Include flags icons'),
          '#default_value' => $this->configuration['advanced']['include_flags'],
        ];
      }
    }
  }
}