SyncCorePoolExport.php in CMS Content Sync 2.1.x
File
src/SyncCorePoolExport.php
View source
<?php
namespace Drupal\cms_content_sync;
use Drupal\cms_content_sync\Controller\ContentSyncSettings;
use Drupal\cms_content_sync\Entity\Pool;
use EdgeBox\SyncCore\Exception\NotFoundException;
class SyncCorePoolExport extends SyncCoreExport {
protected $pool;
public function __construct(Pool $pool) {
parent::__construct($pool
->getClient());
$this->pool = $pool;
}
public function verifySiteId() {
try {
return $this->client
->verifySiteId();
} catch (NotFoundException $e) {
return null;
}
}
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();
if (!$subsequent) {
$this->client
->registerSite($force);
$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;
}
}