public function Config::save in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::save()
- 9 core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::save()
File
- core/
lib/ Drupal/ Core/ Config/ Config.php, line 201
Class
- Config
- Defines the default configuration object.
Namespace
Drupal\Core\ConfigCode
public function save($has_trusted_data = FALSE) {
// Validate the configuration object name before saving.
static::validateName($this->name);
// If there is a schema for this configuration object, cast all values to
// conform to the schema.
if (!$has_trusted_data) {
if ($this->typedConfigManager
->hasConfigSchema($this->name)) {
// Ensure that the schema wrapper has the latest data.
$this->schemaWrapper = NULL;
$this->data = $this
->castValue(NULL, $this->data);
}
else {
foreach ($this->data as $key => $value) {
$this
->validateValue($key, $value);
}
}
}
// Potentially configuration schema could have changed the underlying data's
// types.
$this
->resetOverriddenData();
$this->storage
->write($this->name, $this->data);
if (!$this->isNew) {
Cache::invalidateTags($this
->getCacheTags());
}
$this->isNew = FALSE;
$this->eventDispatcher
->dispatch(new ConfigCrudEvent($this), ConfigEvents::SAVE);
$this->originalData = $this->data;
return $this;
}