You are here

public function Embed::migrate in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 2.0.x src/Controller/Embed.php \Drupal\cms_content_sync\Controller\Embed::migrate()
1 call to Embed::migrate()
Embed::site in src/Controller/Embed.php

File

src/Controller/Embed.php, line 44

Class

Embed
Class Embed provides helpers to embed Sync Core functionality into the site.

Namespace

Drupal\cms_content_sync\Controller

Code

public function migrate() {
  $this
    ->init();
  $all_pools = Pool::getAll();
  $pools = [];
  foreach ($all_pools as $id => $pool) {
    $pools[] = [
      'machineName' => $pool
        ->id(),
      'name' => $pool
        ->label(),
      'exported' => $pool
        ->v2Ready(),
    ];
  }
  $all_flows = Flow::getAll();
  $flows = [];
  $pushes = false;
  foreach ($all_flows as $id => $flow) {
    if (Flow::TYPE_PULL !== $flow->type) {
      $pushes = true;
    }
    $flows[] = [
      'machineName' => $flow
        ->id(),
      'name' => $flow
        ->label(),
      'exported' => $flow
        ->v2Ready(),
    ] + Migration::getFullFlowStatus($flow);
  }
  $health_module_enabled = \Drupal::moduleHandler()
    ->moduleExists('cms_content_sync_health');
  $embed = $this->embedService
    ->migrate($this->params + [
    'pools' => $pools,
    'flows' => $flows,
    'migrated' => false,
    'settings' => [
      'mustEnableHealthSubmodule' => $pushes && !$health_module_enabled,
      'pushToV2Url' => Url::fromRoute('view.content_sync_entity_status.entity_status_overview', [], [
        'query' => [
          'v2' => 'yes',
        ],
        'absolute' => true,
      ])
        ->toString(),
      'pullManuallyFromV2Url' => $health_module_enabled ? Url::fromRoute('entity.cms_content_sync.content', [], [
        'query' => [
          'v2' => 'yes',
        ],
        'absolute' => true,
      ])
        ->toString() : null,
      'switched' => Migration::alwaysUseV2(),
    ],
  ]);
  return $this
    ->run($embed, DrupalApplication::get()
    ->getSiteUuid() ? [
    'form' => \Drupal::formBuilder()
      ->getForm(MigrationForm::class),
  ] : []);
}