You are here

public function SyncCorePoolExport::prepareBatch in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 src/SyncCorePoolExport.php \Drupal\cms_content_sync\SyncCorePoolExport::prepareBatch()
  2. 2.0.x src/SyncCorePoolExport.php \Drupal\cms_content_sync\SyncCorePoolExport::prepareBatch()

Prepare the Sync Core push as a batch operation. Return a batch array with single steps to be executed.

Return value

\EdgeBox\SyncCore\Interfaces\IBatch

Throws

\EdgeBox\SyncCore\Exception\SyncCoreException

Overrides SyncCoreExport::prepareBatch

File

src/SyncCorePoolExport.php, line 46

Class

SyncCorePoolExport

Namespace

Drupal\cms_content_sync

Code

public function prepareBatch($subsequent = false, $force = false) {
  $base_url = ContentSyncSettings::getInstance()
    ->getSiteBaseUrl();
  if (empty($base_url)) {
    throw new \Exception('Please provide a base_url via settings or drush command.');
  }
  $batch = $this->client
    ->batch();

  // Skip creation of base entities if they are already created.
  if (!$subsequent) {

    // Register site independently of batch operations.
    $this->client
      ->registerSite($force);

    // Enable previews used in the pull dashboard independently of batch operations.
    // @todo Only do this if any Flow is actually pulling manually.
    $this->client
      ->getConfigurationService()
      ->enableEntityPreviews(_cms_content_sync_is_cloud_version());
  }
  $this->client
    ->getConfigurationService()
    ->usePool($this->pool->id, $this->pool
    ->label())
    ->addToBatch($batch);
  $this->client
    ->getConfigurationService()
    ->usePool($this->pool->id, $this->pool
    ->label())
    ->addToBatch($batch);
  return $batch;
}