You are here

private function ConfigSplitCliService::tryImport in Configuration Split 2.0.x

Try importing the storage.

Parameters

\Drupal\Core\Config\StorageInterface $storage: The storage to import.

object $io: The io object.

callable $t: The translation function.

Return value

bool The success status.

3 calls to ConfigSplitCliService::tryImport()
ConfigSplitCliService::ioActivate in src/ConfigSplitCliService.php
Handle the activation interaction.
ConfigSplitCliService::ioDeactivate in src/ConfigSplitCliService.php
Handle the deactivation interaction.
ConfigSplitCliService::ioImport in src/ConfigSplitCliService.php
Handle the import interaction.

File

src/ConfigSplitCliService.php, line 370

Class

ConfigSplitCliService
The CLI service class for interoperability.

Namespace

Drupal\config_split

Code

private function tryImport(StorageInterface $storage, $io, callable $t) : bool {
  try {
    $status = $this
      ->import($storage);
    switch ($status) {
      case ConfigSplitCliService::COMPLETE:
        $io
          ->success($t("Configuration successfully imported."));
        return TRUE;
      case ConfigSplitCliService::NO_CHANGES:
        $io
          ->text($t("There are no changes to import."));
        return TRUE;
      case ConfigSplitCliService::ALREADY_IMPORTING:
        $io
          ->error($t("Another request may be synchronizing configuration already."));
        return FALSE;
      default:
        $io
          ->error($t("Something unexpected happened"));
        return FALSE;
    }
  } catch (ConfigImporterException $e) {
    $io
      ->error($t('There have been errors importing: @errors', [
      '@errors' => strip_tags(implode("\n", $this
        ->getErrors())),
    ]));
    return FALSE;
  }
}