You are here

protected static function Migration::setPoolV2Ready in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 2.0.x src/Controller/Migration.php \Drupal\cms_content_sync\Controller\Migration::setPoolV2Ready()
2 calls to Migration::setPoolV2Ready()
Migration::runPoolExport in src/Controller/Migration.php
Migration::runSwitch in src/Controller/Migration.php

File

src/Controller/Migration.php, line 356

Class

Migration
Migration Embed provides methods and a UI to migrate from Content Sync v1 to Content Sync v2.

Namespace

Drupal\cms_content_sync\Controller

Code

protected static function setPoolV2Ready($pool, $switch = false) {

  // TODO: Change all usages of config.factory in this class to use local
  //  key value store instead.
  $settings = \Drupal::service('config.factory')
    ->getEditable('cms_content_sync.migration');
  self::$pool_statuses = $settings
    ->get('cms_content_sync_v2_pool_statuses');
  if (!self::$pool_statuses) {
    self::$pool_statuses = [];
  }
  if ($switch) {
    self::$pool_statuses[$pool->id] = Pool::V2_STATUS_ACTIVE;
    unset($pool->backend_url);
    $pool
      ->save();
  }
  else {
    self::$pool_statuses[$pool->id] = Pool::V2_STATUS_EXPORTED;
  }
  $settings
    ->set('cms_content_sync_v2_pool_statuses', self::$pool_statuses)
    ->save();
}