You are here

public static function Config::set in Openlayers 7.3

Sets a configuration value.

Parameters

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

mixed $value: The value to set.

Return value

array The configuration array.

1 call to Config::set()
openlayers_ui_admin_settings_submit in modules/openlayers_ui/includes/openlayers_ui.admin.inc
Submit callback of the Openlayers settings page.

File

src/Config.php, line 96
Class Config.

Class

Config
Class Config.

Namespace

Drupal\openlayers

Code

public static function set($parents, $value) {
  $config = \Drupal::service('variable')
    ->get('openlayers_config', array());
  if (is_string($parents)) {
    $parents = explode('.', $parents);
  }
  $ref =& $config;
  foreach ($parents as $parent) {
    if (isset($ref) && !is_array($ref)) {
      $ref = array();
    }
    $ref =& $ref[$parent];
  }
  $ref = $value;
  \Drupal::service('variable')
    ->set('openlayers_config', $config);
  return $config;
}