1.20.x config_file_storage.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

drivers/config_file/config_file_storage.inc, line 132

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;
}