public static function FlowControllerSimple::createFlow in CMS Content Sync 2.1.x
Create a flow configuration programmatically.
Parameters
$flow_name:
string $flow_id:
bool $status:
array $dependencies:
$configurations:
bool $force_update:
Return value
2 calls to FlowControllerSimple::createFlow()
- MigratePull::createFlow in modules/
cms_content_sync_migrate_acquia_content_hub/ src/ Form/ MigratePull.php - Create the CMS Content Hub pull flow for the content hub filter.
- MigratePush::createFlow in modules/
cms_content_sync_migrate_acquia_content_hub/ src/ Form/ MigratePush.php
File
- src/
Controller/ FlowControllerSimple.php, line 51
Class
Namespace
Drupal\cms_content_sync\ControllerCode
public static function createFlow(string $type, string $flow_name, ?string $flow_id = null, $status = true, ?array $pools = null, array $dependencies = [], bool $force_update = false) {
$flows = Flow::getAll(true);
// If no flow_id is given, create one.
if (empty($flow_id)) {
$flow_id = strtolower($flow_name);
$flow_id = preg_replace('@[^a-z0-9_]+@', '_', $flow_id);
}
if (!$force_update && array_key_exists($flow_id, $flows)) {
\Drupal::messenger()
->addMessage('A flow with the machine name ' . $flow_id . ' already exists. Creation has been skipped.', 'warning');
return $flow_id;
}
$uuid_service = \Drupal::service('uuid');
$language_manager = \Drupal::service('language_manager');
$default_language = $language_manager
->getDefaultLanguage();
$config = [
'dependencies' => $dependencies,
];
$flow_config = \Drupal::service('config.factory')
->getEditable('cms_content_sync.flow.' . $flow_id);
// Setup base configurations.
$flow_config
->set('uuid', $uuid_service
->generate())
->set('langcode', $default_language
->getId())
->set('status', $status)
->set('id', $flow_id)
->set('name', $flow_name)
->set('type', $type)
->set('variant', Flow::VARIANT_SIMPLE)
->set('config', $config)
->set('simple_settings', [
'poolAssignment' => self::ASSIGN_ALL_POOLS,
'mode' => self::MODE_AUTOMATICALLY,
'deletions' => true,
'updateBehavior' => PullIntent::PULL_UPDATE_FORCE_AND_FORBID_EDITING,
'ignoreUnpublishedChanges' => true,
'allowExplicitUnpublishing' => true,
'pushMenuItems' => true,
'pushPreviews' => true,
'mergeLocalChanges' => true,
'resolveUserReferences' => 'name',
'poolSelectionWidget' => 'checkboxes',
'entityTypeSettings' => [],
'pools' => $pools,
]);
$flow_config
->save();
$flows = Flow::getAll(true, true);
return new SimpleFlowSetupHelper($flows[$flow_id]);
}