You are here

protected function ConfigImporterService::export in Config Importer and Tools 8.0

Same name and namespace in other branches
  1. 8.2 src/ConfigImporterService.php \Drupal\config_import\ConfigImporterService::export()
  2. 8 src/ConfigImporterService.php \Drupal\config_import\ConfigImporterService::export()

Export configuration to temporary directory.

Parameters

string $dir: Path to directory.

Throws

\Exception When fails to create temporary directory.

1 call to ConfigImporterService::export()
ConfigImporterService::importConfigs in src/ConfigImporterService.php
Import config files.

File

src/ConfigImporterService.php, line 224

Class

ConfigImporterService
Class ConfigImporterService.

Namespace

Drupal\config_import

Code

protected function export($dir) {
  $result = $this->fileSystem
    ->mkdir($dir);
  if (!$result) {
    throw new \Exception('Failed to create temporary directory: ' . $dir);
  }
  $source_storage = $this->configStorage;
  $destination_storage = new FileStorage($dir);
  $filters = [];
  $this->moduleHandler
    ->alter('config_import_configs', $filters);
  foreach ($source_storage
    ->listAll() as $name) {
    if (in_array($name, $filters)) {
      continue;
    }
    $destination_storage
      ->write($name, $source_storage
      ->read($name));
  }
}