public static function MigratePush::createFlow in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePush::createFlow()
- 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 78
Class
- MigratePush
- Content Sync advanced debug form.
Namespace
Drupal\cms_content_sync_migrate_acquia_content_hub\FormCode
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();
$setup = FlowControllerSimple::createFlow(Flow::TYPE_PUSH, 'Push', 'push_migrated', TRUE, [
$pool_id,
], [
'config' => [
'cms_content_sync.pool.' . $pool_id,
],
], $force_update);
// 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) {
// 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'];
$setup
->enableBundle($entity_type_key, $bundle_key, $override[$entity_type_key][$bundle_key]['push_configuration']['behavior'] === PushIntent::PUSH_AS_DEPENDENCY);
}
elseif ($entity_type_key == 'node') {
$configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = $node_push_behavior;
$setup
->enableBundle($entity_type_key, $bundle_key, false);
}
else {
$configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = PushIntent::PUSH_AS_DEPENDENCY;
$setup
->enableBundle($entity_type_key, $bundle_key, true);
}
}
}
}
$setup
->save();
$flow = $setup
->getFlow();
if (!empty($configurations)) {
\Drupal::messenger()
->addMessage('The pushing flow has been created, please review your settings.');
return [
'flow_id' => $flow->id,
'flow_configuration' => $configurations,
'type' => 'push',
];
}
else {
\Drupal::messenger()
->addMessage('Content Sync Pushing Flow has not been created.', 'warning');
return '';
}
}