1 config.inc public ConfigFileStorage::write($name, array $data)

Writes configuration data to the storage.

Parameters

string $name: The name of a configuration object to save.

array $data: The configuration data to write.

Return value

bool: TRUE on success, FALSE in case of an error.

Overrides ConfigStorageInterface::write

File

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

Class

ConfigFileStorage
Defines the file storage controller.

Code

public function write($name, array $data) {
  // Ensure that the config name is included in the written file.
  $data = array_merge(array('_config_name' => $name), $data);
  $data = $this->encode($data) . "\n";
  $file_path = $this->getFilePath($name);
  $status = @file_put_contents($file_path, $data);
  if ($status === FALSE) {
    throw new ConfigStorageException('Failed to write configuration file: ' . $this->getFilePath($name));
  }
  clearstatcache(FALSE, $file_path);
  return TRUE;
}