diff --git a/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/migrations/servicenow_knowledge_base_articles.yml b/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/migrations/servicenow_knowledge_base_articles.yml index 7079d9ae8..ebc6d2053 100644 --- a/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/migrations/servicenow_knowledge_base_articles.yml +++ b/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/migrations/servicenow_knowledge_base_articles.yml @@ -23,6 +23,9 @@ source: - name: servicenow_text label: 'ServiceNow text' selector: text + - name: servicenow_workflow_state + label: 'ServiceNow workflow state' + selector: workflow_state ids: servicenow_number: type: string @@ -36,8 +39,9 @@ process: source: servicenow_title plugin: layout_builder_sections moderation_state: - plugin: default_value - default_value: 'published' + plugin: callback + callable: ys_servicenow_moderation_state_transformation + source: servicenow_workflow_state destination: plugin: 'entity:node' default_bundle: page diff --git a/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/ys_servicenow.module b/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/ys_servicenow.module index b01c6f271..5609e3bc6 100644 --- a/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/ys_servicenow.module +++ b/web/profiles/custom/yalesites_profile/modules/custom/ys_servicenow/ys_servicenow.module @@ -41,3 +41,16 @@ function ys_servicenow_url_endpoint(MigrationInterface $migration): array { return []; } + +/** + * Any state other than "Published" is unpublished. + */ +function ys_servicenow_moderation_state_transformation($value) { + $unpublished_state = 'archive'; + + $published_states = [ + 'Published' => 'published', + ]; + + return $published_states[$value] ?? $unpublished_state; +}