public static function MigratePull::createFlow in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 8 modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePull.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePull::createFlow()
- 2.1.x modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePull.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePull::createFlow()
Create the CMS Content Hub pull flow for the content hub filter.
Parameters
string $pool_id:
string $node_push_behavior:
string $pull_updates_behavior:
\Drupal\acquia_contenthub_subscriber\Entity\ContentHubFilter $content_hub_filter:
bool $force_update:
array $override:
Return value
mixed|string
2 calls to MigratePull::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/ MigratePull.php, line 115
Class
- MigratePull
- Migrate a Acquia Content Hub Filter to Content Sync.
Namespace
Drupal\cms_content_sync_migrate_acquia_content_hub\FormCode
public static function createFlow($pool_id, $node_push_behavior, $pull_updates_behavior, $content_hub_filter, $force_update = FALSE, $override = NULL) {
$configurations = [];
// Since Acquia does not save the relation between entity types and bundles
// we need to take care of the mapping.
$content_hub_entity_types = $content_hub_filter
->getEntityTypes();
$content_hub_bundles = $content_hub_filter
->getBundles();
$tags = MigrationBase::getTermsFromFilter($content_hub_filter->tags);
foreach ($content_hub_entity_types as $content_hub_entity_type) {
$entity_type_bundles = \Drupal::service('entity_type.bundle.info')
->getBundleInfo($content_hub_entity_type);
foreach ($content_hub_bundles as $content_hub_bundle_key => $content_hub_bundle) {
if (array_key_exists($content_hub_bundle, $entity_type_bundles)) {
// General configurations.
$configurations[$content_hub_entity_type][$content_hub_bundle]['import_configuration'] = [
'import_deletion' => TRUE,
'allow_local_deletion_of_import' => TRUE,
'import_updates' => $pull_updates_behavior,
];
// Pool configuration.
$configurations[$content_hub_entity_type][$content_hub_bundle]['import_configuration']['import_pools'][$pool_id] = Pool::POOL_USAGE_FORCE;
// Import everything beside nodes as dependencies but allow overrides.
if (isset($override[$content_hub_entity_type][$content_hub_bundle]['import_configuration']['behavior'])) {
$configurations[$content_hub_entity_type][$content_hub_bundle]['import_configuration']['behavior'] = $override[$content_hub_entity_type][$content_hub_bundle]['import_configuration']['behavior'];
}
elseif ($content_hub_entity_type == 'node') {
$configurations[$content_hub_entity_type][$content_hub_bundle]['import_configuration']['behavior'] = PullIntent::PULL_AUTOMATICALLY;
if (!empty($tags)) {
$configurations[$content_hub_entity_type][$content_hub_bundle]['tags'] = $tags;
}
}
else {
$configurations[$content_hub_entity_type][$content_hub_bundle]['import_configuration']['behavior'] = PullIntent::PULL_AS_DEPENDENCY;
}
}
}
}
\Drupal::messenger()
->addMessage('The pull flow has been created, please review your settings.');
return [
'flow_id' => Flow::createFlow($content_hub_filter
->label(), $content_hub_filter
->id() . '_migrated', TRUE, [
'config' => [
'cms_content_sync.pool.' . $pool_id,
],
], $configurations, $force_update),
'flow_configuration' => $configurations,
'type' => 'pull',
];
}