1 config.inc public Config::set($key, $value)

Sets a value in this configuration object.

Note that this will save a NULL value. If wanting to unset a key from the configuration, use Config::clear($key).

Parameters

string $key: Identifier to store value in configuration.

mixed $value: Value to associate with identifier.

Return value

Config: The configuration object.

File

core/includes/config.inc, line 704
This is the API for configuration storage.

Class

Config
Defines the default configuration object.

Code

public function set($key, $value) {
  if (!$this->isLoaded) {
    $this->load();
  }

  // The dot/period is a reserved character; it may appear between keys, but
  // not within keys.
  $parts = explode('.', $key);
  if (count($parts) == 1) {
    $this->data[$key] = $value;
  }
  else {
    $data = &$this->data;
    $last_key = array_pop($parts);
    foreach ($parts as $part) {
      if (!isset($data)) {
        $data[$part] = array();
      }
      $data = &$data[$part];
    }
    $data[$last_key] = $value;
  }
  $this->validated = FALSE;

  return $this;
}