You are here

public function CliService::configuration_export in CMS Content Sync 8

Same name in this branch
  1. 8 src/Cli/CliService.php \Drupal\cms_content_sync\Cli\CliService::configuration_export()
  2. 8 modules/cms_content_sync_developer/src/Cli/CliService.php \Drupal\cms_content_sync_developer\Cli\CliService::configuration_export()
Same name and namespace in other branches
  1. 2.1.x src/Cli/CliService.php \Drupal\cms_content_sync\Cli\CliService::configuration_export()
  2. 2.0.x src/Cli/CliService.php \Drupal\cms_content_sync\Cli\CliService::configuration_export()

Export the configuration to the Sync Core.

Parameters

ICLIIO $io: The CLI service which allows interoperability

array $options: An array containing the option parameters provided by Drush

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\EdgeBox\SyncCore\Exception\SyncCoreException

\Exception

File

src/Cli/CliService.php, line 34

Class

CliService

Namespace

Drupal\cms_content_sync\Cli

Code

public function configuration_export($io, $options) {
  $io
    ->text('Validating Pools...');
  foreach (Pool::getAll() as $pool) {
    if (!PoolExport::validateBaseUrl($pool)) {
      throw new \Exception('The site does not have a valid base url. The base url must not contain "localhost" and is not allowed to be an IP address. The base url of the site can be configured at the CMS Content Sync settings page.');
    }
    $exporter = new SyncCorePoolExport($pool);
    $sites = $exporter
      ->verifySiteId();
    if (!$options['force'] && $sites && count($sites)) {
      throw new \Exception('Another site with id ' . array_keys($sites)[0] . ' and base url ' . array_values($sites)[0] . ' already exists for the pool "' . $pool->id . '"');
    }
  }
  $io
    ->text('Finished validating Pools.');
  $io
    ->text('Starting Flow export...');
  $count = 0;
  foreach (Flow::getAll() as $flow) {
    $io
      ->text('> Exporting Flow ' . $flow
      ->label() . '...');
    $exporter = new SyncCoreFlowExport($flow);
    $batch = $exporter
      ->prepareBatch($options['force']);
    $io
      ->text('>> Executing ' . $batch
      ->count() . ' operations...');
    $batch
      ->executeAll();
    ++$count;
  }
  $io
    ->text('Finished export of ' . $count . ' Flow(s).');
  $io
    ->success('Export completed.');
}