You are here

class SyncCorePoolExport in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/SyncCorePoolExport.php \Drupal\cms_content_sync\SyncCorePoolExport
  2. 2.0.x src/SyncCorePoolExport.php \Drupal\cms_content_sync\SyncCorePoolExport

Hierarchy

Expanded class hierarchy of SyncCorePoolExport

4 files declare their use of SyncCorePoolExport
CliService.php in src/Cli/CliService.php
FlowExport.php in src/Controller/FlowExport.php
Pool.php in src/Entity/Pool.php
PoolExport.php in src/Controller/PoolExport.php

File

src/SyncCorePoolExport.php, line 9

Namespace

Drupal\cms_content_sync
View source
class SyncCorePoolExport extends SyncCoreExport {

  /**
   * @var \Drupal\cms_content_sync\Entity\Pool
   */
  protected $pool;

  /**
   * SyncCorePoolExport constructor.
   *
   * @param \Drupal\cms_content_sync\Entity\Pool $pool
   *                                                   The pool this exporter is used for
   */
  public function __construct(Pool $pool) {
    parent::__construct($pool
      ->getClient());
    $this->pool = $pool;
  }

  /**
   * Check if another site has already connected to this pool with the same site ID.
   *
   * @return null|array
   */
  public function verifySiteId() {
    try {
      return $this->client
        ->verifySiteId();
    } catch (NotFoundException $e) {
      return null;
    }
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SyncCoreExport::$client protected property
SyncCoreExport::getClient public function
SyncCorePoolExport::$pool protected property
SyncCorePoolExport::prepareBatch public function Prepare the Sync Core push as a batch operation. Return a batch array with single steps to be executed. Overrides SyncCoreExport::prepareBatch
SyncCorePoolExport::verifySiteId public function Check if another site has already connected to this pool with the same site ID.
SyncCorePoolExport::__construct public function SyncCorePoolExport constructor. Overrides SyncCoreExport::__construct