1 config.inc public ConfigFileStorage::importArchive($file_uri)

Import an archive of configuration files into the config storage managed by this object.

Parameters

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

Return value

bool: TRUE on success, FALSE otherwise.

Throws

ConfigStorageException

Overrides ConfigStorageInterface::importArchive

File

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

Class

ConfigFileStorage
Defines the file storage controller.

Code

public function importArchive($file_uri) {
  $realpath = backdrop_realpath($file_uri);

  try {
    $archiver = new ArchiverTar($realpath);
    // Only extract JSON files, ignoring anything else in the archive.
    $file_list = preg_grep('/.json$/', $archiver->listContents());
    if ($file_list) {
      $archiver->extract($this->directory, $file_list);
    }
  }
  catch (\Exception $e) {
    watchdog('config', 'Could not extract the archive @uri: @error', array('@uri' => $file_uri, '@error' => $e->getMessage()), WATCHDOG_ERROR);
    throw new ConfigStorageException($e->getMessage(), 0, $e);
  }
  return TRUE;
}