You are here

public static function Config::get in Geocoder 7.2

Fetches a configuration value.

Parameters

string|array $parents: The path to the configuration value. Strings use dots as path separator.

string|array $default_value: The default value to use if the config value isn't set.

Return value

mixed The configuration value.

2 calls to Config::get()
GeocoderPlugin::cache_get in src/Plugin/GeocoderPlugin.php
Get a cache object based on the cache ID.
GeocoderPlugin::cache_set in src/Plugin/GeocoderPlugin.php
Stores data in the persistent cache.

File

src/Config.php, line 45
Class Config.

Class

Config
Class Config.

Namespace

Drupal\geocoder

Code

public static function get($parents, $default_value = NULL) {
  $options = \Drupal::service('variable')
    ->get('geocoder_config', array());
  if (is_string($parents)) {
    $parents = explode('.', $parents);
  }
  if (is_array($parents)) {
    $notfound = FALSE;
    foreach ($parents as $parent) {
      if (array_key_exists($parent, $options)) {
        $options = $options[$parent];
      }
      else {
        $notfound = TRUE;
        break;
      }
    }
    if (!$notfound) {
      return $options;
    }
  }
  $value = Config::defaults(implode('.', $parents));
  if (isset($value)) {
    return $value;
  }
  if (is_null($default_value)) {
    return FALSE;
  }
  return $default_value;
}