| 1 config.inc | public Config::save() |
Saves the configuration object.
Return value
Config: The configuration object.
File
- core/
includes/ config.inc, line 1087 - This is the API for configuration storage.
Class
- Config
- Defines the default configuration object.
Code
public function save() {
// Validate the configuration object name before saving.
static::validateName($this->name);
if (!$this->isLoaded) {
$this->load();
}
// Ensure config name is saved in the result.
$this->data['_config_name'] = $this->name;
// Ensure all _config_* keys are positioned at the top of the saved data.
$config_keys = array();
foreach ($this->data as $key => $value) {
if (strpos($key, '_config_') === 0) {
$config_keys[$key] = $value;
}
}
ksort($config_keys, SORT_STRING);
$this->data = array_merge($config_keys, $this->data);
$this->storage->write($this->name, $this->data);
$this->isNew = FALSE;
// Empty static caches of this config file.
if ($static = & backdrop_static('config')) {
foreach ($static as $type => $configs) {
if (array_key_exists($this->name, $configs)) {
unset($static[$type][$this->name]);
}
}
}
return $this;
}