Skip to content

Commit

Permalink
feat(YSP-593): use workflow_state to drive publish status
Browse files Browse the repository at this point in the history
  • Loading branch information
dblanken-yale committed Sep 19, 2024
1 parent 4c2ea00 commit 5e0551f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 5e0551f

Please sign in to comment.