You are here

protected function ViewsAutocompleteFiltersController::getExposedInput in Views Autocomplete Filters 8

Collect exposed filter values for setting them to the view.

Parameters

\Drupal\views\ViewExecutable $view: The view.

\Symfony\Component\HttpFoundation\Request $request: The request.

array $expose_options: The options for the exposed filter.

Return value

array|string[] The exposed input.

1 call to ViewsAutocompleteFiltersController::getExposedInput()
ViewsAutocompleteFiltersController::autocomplete in src/Controller/ViewsAutocompleteFiltersController.php
Retrieves suggestions for taxonomy term autocompletion.

File

src/Controller/ViewsAutocompleteFiltersController.php, line 284

Class

ViewsAutocompleteFiltersController
Returns autocomplete responses for taxonomy terms.

Namespace

Drupal\views_autocomplete_filters\Controller

Code

protected function getExposedInput(ViewExecutable $view, Request $request, array $expose_options) {
  $display_handler = $view->display_handler;
  $filters = $display_handler
    ->getOption('filters');
  if (!empty($expose_options['autocomplete_dependent'])) {
    $exposed_input = $view
      ->getExposedInput();
  }
  else {
    $exposed_input = [];

    // Need to reset the default values for exposed filters.
    foreach ($display_handler
      ->getOption('filters') as $name => $filter) {
      if (!empty($filters[$name]['exposed'])) {
        if (!empty($filter['is_grouped'])) {
          $filters[$name]['group_info']['default_group'] = 'All';
        }
        $filters[$name]['value'] = [];
      }
    }
    $display_handler
      ->setOption('filters', $filters);
  }
  $exposed_input[$expose_options['identifier']] = $request->query
    ->get('q');
  return $exposed_input;
}