You are here

public function ViewsBoundaryFilter::getAvailableMapCenterOptions in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/geolocation/MapCenter/ViewsBoundaryFilter.php \Drupal\geolocation\Plugin\geolocation\MapCenter\ViewsBoundaryFilter::getAvailableMapCenterOptions()

For one MapCenter (i.e. boundary filter), return all options (all filters).

Parameters

mixed $context: Context like field formatter, field widget or view.

Return value

array Available center options indexed by ID.

Overrides MapCenterBase::getAvailableMapCenterOptions

1 method overrides ViewsBoundaryFilter::getAvailableMapCenterOptions()
GeometryViewsBoundaryFilter::getAvailableMapCenterOptions in modules/geolocation_geometry/src/Plugin/geolocation/MapCenter/GeometryViewsBoundaryFilter.php
For one MapCenter (i.e. boundary filter), return all options (all filters).

File

src/Plugin/geolocation/MapCenter/ViewsBoundaryFilter.php, line 53

Class

ViewsBoundaryFilter
Derive center from boundary filter.

Namespace

Drupal\geolocation\Plugin\geolocation\MapCenter

Code

public function getAvailableMapCenterOptions($context) {
  $options = [];
  if ($displayHandler = self::getViewsDisplayHandler($context)) {

    /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
    foreach ($displayHandler
      ->getHandlers('filter') as $filter_id => $filter) {
      if ($filter
        ->getPluginId() === 'geolocation_filter_boundary') {

        // Preserve compatibility to v1.
        $options['boundary_filter_' . $filter_id] = $this
          ->t('Boundary filter') . ' - ' . $filter
          ->adminLabel();
      }
    }
  }
  return $options;
}