public function ConfigSplitCliService::ioExport in Configuration Split 8
Same name and namespace in other branches
- 2.0.x src/ConfigSplitCliService.php \Drupal\config_split\ConfigSplitCliService::ioExport()
Handle the export interaction.
Parameters
string|null $split: The split name to export, null for standard export.
\Symfony\Component\Console\Style\StyleInterface|\ConfigSplitDrush8Io $io: The io interface of the cli tool calling the method.
callable $t: The translation function akin to t().
bool $confirmed: Whether the export is already confirmed by the console input.
File
- src/ConfigSplitCliService.php, line 194 
Class
- ConfigSplitCliService
- The CLI service class for interoperability.
Namespace
Drupal\config_splitCode
public function ioExport($split, $io, callable $t, $confirmed = FALSE) {
  if (!$split) {
    $io
      ->warning('Please consider using `drush config:export` instead for exporting all config.');
    $message = $t('Do a normal (including filters) config export?');
    $storage = $this->syncStorage;
    if (!$storage instanceof FilteredStorageInterface) {
      throw new \RuntimeException('Only exporting splits is supported when not using Config Filter 8.x-1.x');
    }
  }
  else {
    $config_name = $this
      ->getSplitName($split);
    $plugin_id = $this
      ->getPluginIdFromConfigName($config_name);
    $filter = $this->configFilterManager
      ->getFilterInstance($plugin_id);
    // Use a GhostStorage so that we only export the split.
    $storage = $this->storageFactory
      ->getFilteredStorage(FileStorageFactory::getSync(), [
      'config.storage.sync',
    ], [
      $plugin_id,
    ]);
    $storage = new FilteredStorage(new GhostStorage($storage), [
      $filter,
    ]);
    $message = $t('The following directories will be purged and used for exporting configuration:');
    $message .= "\n";
    $message .= $this
      ->getDestination($config_name);
    $message .= "\n";
    $message .= $t('Export the configuration?');
  }
  if ($confirmed || $io
    ->confirm($message)) {
    $this
      ->export($storage);
    $io
      ->success($t("Configuration successfully exported."));
  }
}