1 config.inc public ConfigDatabaseStorage::exportArchive($archive_file_uri)

Export an archive of configuration files from the config storage managed by this object.

Parameters

string $file_uri: The URI of the tar archive file to create.

Return value

bool: TRUE on success, FALSE otherwise.

Throws

ConfigStorageException

Overrides ConfigStorageInterface::exportArchive

File

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

Class

ConfigDatabaseStorage
Defines the database storage controller.

Code

public function exportArchive($archive_file_uri) {
  $temp_directory = file_create_filename('config', file_directory_temp());
  file_prepare_directory($temp_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  $data = db_select($this->table, 'c', array('target' => $this->database))
    ->fields('c')
    ->execute()
    ->fetchAllAssoc('name', PDO::FETCH_ASSOC);
  foreach ($data as $config_name => $row) {
    file_put_contents($temp_directory . '/' . $config_name . '.json', $row['data']);
  }

  // And tar it up.
  $archiver = new ArchiverTar($archive_file_uri);
  $config_files = array();
  foreach (array_keys($data) as $config_name) {
    $config_files[] = $temp_directory . '/' . $config_name . '.json';
  }
  $archiver->getArchive()->createModify($config_files, '', $temp_directory);
  file_unmanaged_delete_recursive($temp_directory);
}