You are here

public function ConfigSplitCliService::ioExport in Configuration Split 2.0.x

Same name and namespace in other branches
  1. 8 src/ConfigSplitCliService.php \Drupal\config_split\ConfigSplitCliService::ioExport()

Handle the export interaction.

Parameters

string $split: The split name to export.

\Symfony\Component\Console\Style\StyleInterface|object $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 103

Class

ConfigSplitCliService
The CLI service class for interoperability.

Namespace

Drupal\config_split

Code

public function ioExport(string $split, $io, callable $t, bool $confirmed = FALSE) : bool {
  $config = $this
    ->getSplitFromArgument($split, $io, $t);
  if ($config === NULL) {
    return FALSE;
  }
  if (!$config
    ->get('status')) {
    $io
      ->warning("Inactive splits can not not be exported.");
    return FALSE;
  }
  $message = $t('Export the split config configuration?');
  if ($confirmed || $io
    ->confirm($message)) {
    $target = $this->manager
      ->singleExportTarget($config);
    self::replaceStorageContents($this->manager
      ->singleExportPreview($config), $target);
    $io
      ->success($t("Configuration successfully exported."));
  }
  return TRUE;
}