You are here

protected function SearchApiLocationArgumentTrait::addFieldOptions in Search API Location 8

Adds a location filter to an existing "search_api_location" array.

Parameters

array $original_options: The existing options.

array $add_options: The options to add.

string $field: The field for which to add the options.

2 calls to SearchApiLocationArgumentTrait::addFieldOptions()
SearchApiLocationPoint::query in modules/search_api_location_views/src/Plugin/views/argument/SearchApiLocationPoint.php
Set up the query for this argument.
SearchApiLocationRadius::query in modules/search_api_location_views/src/Plugin/views/argument/SearchApiLocationRadius.php
Set up the query for this argument.

File

modules/search_api_location_views/src/Plugin/views/argument/SearchApiLocationArgumentTrait.php, line 20

Class

SearchApiLocationArgumentTrait
Provides common methods for Search API Location contextual filters.

Namespace

Drupal\search_api_location_views\Plugin\views\argument

Code

protected function addFieldOptions(array &$original_options, array $add_options, $field) {
  foreach ($original_options as $key => &$field_options) {
    if ($field_options['field'] == $field) {

      // Found existing filter. Add our options and return.
      $field_options = $add_options + $field_options;
      return;
    }
  }

  // Field not yet in options, create new element.
  $add_options['field'] = $field;
  $original_options[] = $add_options;
}