You are here

public function IpGeoLocPluginStyleLeaflet::getRegionFieldDepth in IP Geolocation Views & Maps 8

Pending doc.

1 call to IpGeoLocPluginStyleLeaflet::getRegionFieldDepth()
IpGeoLocPluginStyleLeaflet::addClusterDifferentiator in src/Plugin/views/style/IpGeoLocPluginStyleLeaflet.php
Form part definition.

File

src/Plugin/views/style/IpGeoLocPluginStyleLeaflet.php, line 1110

Class

IpGeoLocPluginStyleLeaflet
Views Style plugin extension for Leaflet (if enabled).

Namespace

Drupal\ip_geoloc\Plugin\views\style

Code

public function getRegionFieldDepth($region_field) {
  $type = $region_field
    ->get('type');
  if (empty($type)) {

    // Dodgy business. Return 1 and hope for the best.
    return 1;
  }
  if ($type === 'addressfield') {
    return 4;
  }
  $settings = $region_field
    ->getSettings();

  //if (empty($settings['allowed_values'])) {
  if ($settings['target_type'] != 'taxonomy_term') {
    return 1;
  }

  // Possibly a taxonomy or list.
  $depth = 0;

  //@TODO Find out how to migrate this

  // foreach ($region_field['settings']['allowed_values'] as $tree) {
  //   if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
  //     if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
  //       foreach ($terms as $term) {
  //         $depth = max($term->depth, $depth);
  //       }
  //       break;
  //     }
  //   }
  // }
  return $depth + 1;
}