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

drivers/config_file/config_file_storage.inc, line 237

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