You are here

public static function MigratePush::createFlow in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePush::createFlow()
  2. 2.0.x modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePush::createFlow()

Parameters

string $pool_id:

string $node_push_behavior:

string $pull_updates_behavior:

bool $force_update:

Return value

array|string

2 calls to MigratePush::createFlow()
drush_cms_content_sync_migrate_acquia_content_hub_content_sync_migrate_acquia_content_hub in modules/cms_content_sync_migrate_acquia_content_hub/cms_content_sync_migrate_acquia_content_hub.drush.inc
Migrate Acquia Content Hub.
MigrationBase::submitForm in modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigrationBase.php
Form submission handler.

File

modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php, line 77

Class

MigratePush
Content Sync advanced debug form.

Namespace

Drupal\cms_content_sync_migrate_acquia_content_hub\Form

Code

public static function createFlow($pool_id, $node_push_behavior, $pull_updates_behavior, $force_update = FALSE, $override = NULL) {

  // Get Acquia Content Hub configurations.
  $content_hub_configrations = MigratePush::getAcquiaContentHubConfigrations();

  // Create a new flow based on the given Acquia Content Hub configurations.
  foreach ($content_hub_configrations as $entity_type_key => $content_hub_configration) {

    // If no bundles are configured, the entity type can be skipped.
    if (!in_array(TRUE, $content_hub_configration)) {
      continue;
    }
    foreach ($content_hub_configration as $bundle_key => $bundle) {
      if ($bundle) {

        // @todo More Handler options?
        // General configurations.
        $configurations[$entity_type_key][$bundle_key]['push_configuration'] = [
          'export_deletion_settings' => TRUE,
        ];
        $configurations[$entity_type_key][$bundle_key]['push_configuration']['export_pools'] = [];
        $usage = $entity_type_key == 'node' ? Pool::POOL_USAGE_ALLOW : Pool::POOL_USAGE_FORCE;
        $configurations[$entity_type_key][$bundle_key]['push_configuration']['export_pools'][$pool_id] = $usage;

        // Export everything beside nodes as dependencies, but allow overrides.
        if (isset($override[$entity_type_key][$bundle_key]['push_configuration']['behavior'])) {
          $configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = $override[$entity_type_key][$bundle_key]['push_configuration']['behavior'];
        }
        elseif ($entity_type_key == 'node') {
          $configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = $node_push_behavior;
        }
        else {
          $configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = PushIntent::PUSH_AS_DEPENDENCY;
        }
      }
    }
  }
  if (!empty($configurations)) {
    \Drupal::messenger()
      ->addMessage('The pushing flow has been created, please review your settings.');
    return [
      'flow_id' => Flow::createFlow('Push', 'push_migrated', TRUE, [
        'config' => [
          'cms_content_sync.pool.' . $pool_id,
        ],
      ], $configurations, $force_update),
      'flow_configuration' => $configurations,
      'type' => 'push',
    ];
  }
  else {
    \Drupal::messenger()
      ->addMessage('Content Sync Pushing Flow has not been created.', 'warning');
    return '';
  }
}