Loading core/modules/content_moderation/config/install/workflows.workflow.editorial.yml +22 −26 Changes for core/modules/content_moderation/config/install/workflows.workflow.editorial.yml: 22 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -5,17 +5,39 @@ dependencies: - content_moderation id: editorial label: 'Editorial workflow' type: content_moderation type_settings: states: archived: label: Archived weight: 5 published: false default_revision: true draft: label: Draft published: false default_revision: false weight: -5 published: label: Published published: true default_revision: true weight: 0 transitions: create_new_draft: label: 'Create New Draft' to: draft weight: 0 from: - draft - published publish: label: Publish to: published weight: 1 from: - draft - published archive: label: Archive from: Loading @@ -34,30 +56,4 @@ transitions: - archived to: published weight: 4 create_new_draft: label: 'Create New Draft' from: - draft - published to: draft weight: 0 publish: label: Publish from: - draft - published to: published weight: 1 type: content_moderation type_settings: states: archived: published: false default_revision: true draft: published: false default_revision: false published: published: true default_revision: true entity_types: { } core/modules/content_moderation/config/schema/content_moderation.schema.yml +17 −9 Changes for core/modules/content_moderation/config/schema/content_moderation.schema.yml: 17 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -6,15 +6,8 @@ views.filter.latest_revision: type: string label: 'Value' workflow.type_settings.content_moderation: type: mapping mapping: states: type: sequence label: 'Additional state configuration for content moderation' sequence: type: mapping label: 'States' content_moderation.state: type: workflows.state mapping: published: type: boolean Loading @@ -22,6 +15,21 @@ workflow.type_settings.content_moderation: default_revision: type: boolean label: 'Is default revision' workflow.type_settings.content_moderation: type: mapping mapping: states: type: sequence label: 'Content moderation states' sequence: type: content_moderation.state label: 'States' transitions: type: sequence sequence: type: workflows.transition label: 'Transitions' entity_types: type: sequence label: 'Entity types' Loading core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +25 −16 Changes for core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php: 25 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -91,20 +91,6 @@ public static function create(ContainerInterface $container, array $configuratio ); } /** * {@inheritdoc} */ public function initializeWorkflow(WorkflowInterface $workflow) { $workflow ->addState('draft', $this->t('Draft')) ->setStateWeight('draft', -5) ->addState('published', $this->t('Published')) ->setStateWeight('published', 0) ->addTransition('create_new_draft', $this->t('Create New Draft'), ['draft', 'published'], 'draft') ->addTransition('publish', $this->t('Publish'), ['draft', 'published'], 'published'); return $workflow; } /** * {@inheritdoc} */ Loading @@ -119,7 +105,7 @@ public function checkWorkflowAccess(WorkflowInterface $entity, $operation, Accou * {@inheritdoc} */ public function decorateState(StateInterface $state) { if (isset($this->configuration['states'][$state->id()])) { if (isset($this->configuration['states'][$state->id()]['published']) && isset($this->configuration['states'][$state->id()]['default_revision'])) { $state = new ContentModerationState($state, $this->configuration['states'][$state->id()]['published'], $this->configuration['states'][$state->id()]['default_revision']); } else { Loading Loading @@ -243,16 +229,39 @@ public function addEntityTypeAndBundle($entity_type_id, $bundle_id) { * {@inheritdoc} */ public function defaultConfiguration() { // This plugin does not store anything per transition. return [ 'states' => [ 'draft' => [ 'label' => 'Draft', 'published' => FALSE, 'default_revision' => FALSE, 'weight' => 0, ], 'published' => [ 'label' => 'Published', 'published' => TRUE, 'default_revision' => TRUE, 'weight' => 1, ], ], 'transitions' => [ 'create_new_draft' => [ 'label' => 'Create New Draft', 'to' => 'draft', 'weight' => 0, 'from' => [ 'draft', 'published', ], ], 'publish' => [ 'label' => 'Publish', 'to' => 'published', 'weight' => 1, 'from' => [ 'draft', 'published', ], ], ], 'entity_types' => [], Loading core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php +12 −0 Changes for core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ public function testNewWorkflow() { $this->assertSession()->pageTextContains('Create New Draft'); $this->assertSession()->pageTextContains('Publish'); $this->assertSession()->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test_workflow/state/draft/delete'); $this->assertSession()->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test_workflow/state/published/delete'); // Ensure after a workflow is created, the bundle information can be // refreshed. $entity_bundle_info->clearCachedBundles(); Loading @@ -63,6 +66,15 @@ public function testNewWorkflow() { 'type_settings[content_moderation][default_revision]' => FALSE, ], 'Save'); $this->assertSession()->pageTextContains('Created Test State state.'); $this->assertSession()->linkByHrefExists('/admin/config/workflow/workflows/manage/test_workflow/state/test_state/delete'); // Check there is a link to delete a default transition. $this->assertSession()->linkByHrefExists('/admin/config/workflow/workflows/manage/test_workflow/transition/publish/delete'); // Delete the transition. $this->drupalGet('/admin/config/workflow/workflows/manage/test_workflow/transition/publish/delete'); $this->submitForm([], 'Delete'); // The link to delete the transition should now be gone. $this->assertSession()->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test_workflow/transition/publish/delete'); // Ensure that the published settings cannot be changed. $this->drupalGet('admin/config/workflow/workflows/manage/test_workflow/state/published'); Loading core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php +2 −26 Changes for core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php: 2 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -55,37 +55,13 @@ public function permissionsTestCases() { 'id' => 'simple_workflow', 'label' => 'Simple Workflow', 'type' => 'content_moderation', 'transitions' => [ 'publish' => [ 'label' => 'Publish', 'from' => ['draft'], 'to' => 'published', 'weight' => 0, ], 'unpublish' => [ 'label' => 'Unpublish', 'from' => ['published'], 'to' => 'draft', 'weight' => 0, ], ], 'states' => [ 'draft' => [ 'label' => 'Draft', 'weight' => -5, ], 'published' => [ 'label' => 'Published', 'weight' => 0, ], ], ], [ 'use simple_workflow transition publish' => [ 'title' => 'Use <em class="placeholder">Publish</em> transition from <em class="placeholder">Simple Workflow</em> workflow.', ], 'use simple_workflow transition unpublish' => [ 'title' => 'Use <em class="placeholder">Unpublish</em> transition from <em class="placeholder">Simple Workflow</em> workflow.', 'use simple_workflow transition create_new_draft' => [ 'title' => 'Use <em class="placeholder">Create New Draft</em> transition from <em class="placeholder">Simple Workflow</em> workflow.', ], ], ], Loading Loading
core/modules/content_moderation/config/install/workflows.workflow.editorial.yml +22 −26 Changes for core/modules/content_moderation/config/install/workflows.workflow.editorial.yml: 22 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -5,17 +5,39 @@ dependencies: - content_moderation id: editorial label: 'Editorial workflow' type: content_moderation type_settings: states: archived: label: Archived weight: 5 published: false default_revision: true draft: label: Draft published: false default_revision: false weight: -5 published: label: Published published: true default_revision: true weight: 0 transitions: create_new_draft: label: 'Create New Draft' to: draft weight: 0 from: - draft - published publish: label: Publish to: published weight: 1 from: - draft - published archive: label: Archive from: Loading @@ -34,30 +56,4 @@ transitions: - archived to: published weight: 4 create_new_draft: label: 'Create New Draft' from: - draft - published to: draft weight: 0 publish: label: Publish from: - draft - published to: published weight: 1 type: content_moderation type_settings: states: archived: published: false default_revision: true draft: published: false default_revision: false published: published: true default_revision: true entity_types: { }
core/modules/content_moderation/config/schema/content_moderation.schema.yml +17 −9 Changes for core/modules/content_moderation/config/schema/content_moderation.schema.yml: 17 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -6,15 +6,8 @@ views.filter.latest_revision: type: string label: 'Value' workflow.type_settings.content_moderation: type: mapping mapping: states: type: sequence label: 'Additional state configuration for content moderation' sequence: type: mapping label: 'States' content_moderation.state: type: workflows.state mapping: published: type: boolean Loading @@ -22,6 +15,21 @@ workflow.type_settings.content_moderation: default_revision: type: boolean label: 'Is default revision' workflow.type_settings.content_moderation: type: mapping mapping: states: type: sequence label: 'Content moderation states' sequence: type: content_moderation.state label: 'States' transitions: type: sequence sequence: type: workflows.transition label: 'Transitions' entity_types: type: sequence label: 'Entity types' Loading
core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +25 −16 Changes for core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php: 25 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -91,20 +91,6 @@ public static function create(ContainerInterface $container, array $configuratio ); } /** * {@inheritdoc} */ public function initializeWorkflow(WorkflowInterface $workflow) { $workflow ->addState('draft', $this->t('Draft')) ->setStateWeight('draft', -5) ->addState('published', $this->t('Published')) ->setStateWeight('published', 0) ->addTransition('create_new_draft', $this->t('Create New Draft'), ['draft', 'published'], 'draft') ->addTransition('publish', $this->t('Publish'), ['draft', 'published'], 'published'); return $workflow; } /** * {@inheritdoc} */ Loading @@ -119,7 +105,7 @@ public function checkWorkflowAccess(WorkflowInterface $entity, $operation, Accou * {@inheritdoc} */ public function decorateState(StateInterface $state) { if (isset($this->configuration['states'][$state->id()])) { if (isset($this->configuration['states'][$state->id()]['published']) && isset($this->configuration['states'][$state->id()]['default_revision'])) { $state = new ContentModerationState($state, $this->configuration['states'][$state->id()]['published'], $this->configuration['states'][$state->id()]['default_revision']); } else { Loading Loading @@ -243,16 +229,39 @@ public function addEntityTypeAndBundle($entity_type_id, $bundle_id) { * {@inheritdoc} */ public function defaultConfiguration() { // This plugin does not store anything per transition. return [ 'states' => [ 'draft' => [ 'label' => 'Draft', 'published' => FALSE, 'default_revision' => FALSE, 'weight' => 0, ], 'published' => [ 'label' => 'Published', 'published' => TRUE, 'default_revision' => TRUE, 'weight' => 1, ], ], 'transitions' => [ 'create_new_draft' => [ 'label' => 'Create New Draft', 'to' => 'draft', 'weight' => 0, 'from' => [ 'draft', 'published', ], ], 'publish' => [ 'label' => 'Publish', 'to' => 'published', 'weight' => 1, 'from' => [ 'draft', 'published', ], ], ], 'entity_types' => [], Loading
core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php +12 −0 Changes for core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ public function testNewWorkflow() { $this->assertSession()->pageTextContains('Create New Draft'); $this->assertSession()->pageTextContains('Publish'); $this->assertSession()->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test_workflow/state/draft/delete'); $this->assertSession()->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test_workflow/state/published/delete'); // Ensure after a workflow is created, the bundle information can be // refreshed. $entity_bundle_info->clearCachedBundles(); Loading @@ -63,6 +66,15 @@ public function testNewWorkflow() { 'type_settings[content_moderation][default_revision]' => FALSE, ], 'Save'); $this->assertSession()->pageTextContains('Created Test State state.'); $this->assertSession()->linkByHrefExists('/admin/config/workflow/workflows/manage/test_workflow/state/test_state/delete'); // Check there is a link to delete a default transition. $this->assertSession()->linkByHrefExists('/admin/config/workflow/workflows/manage/test_workflow/transition/publish/delete'); // Delete the transition. $this->drupalGet('/admin/config/workflow/workflows/manage/test_workflow/transition/publish/delete'); $this->submitForm([], 'Delete'); // The link to delete the transition should now be gone. $this->assertSession()->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test_workflow/transition/publish/delete'); // Ensure that the published settings cannot be changed. $this->drupalGet('admin/config/workflow/workflows/manage/test_workflow/state/published'); Loading
core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php +2 −26 Changes for core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php: 2 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -55,37 +55,13 @@ public function permissionsTestCases() { 'id' => 'simple_workflow', 'label' => 'Simple Workflow', 'type' => 'content_moderation', 'transitions' => [ 'publish' => [ 'label' => 'Publish', 'from' => ['draft'], 'to' => 'published', 'weight' => 0, ], 'unpublish' => [ 'label' => 'Unpublish', 'from' => ['published'], 'to' => 'draft', 'weight' => 0, ], ], 'states' => [ 'draft' => [ 'label' => 'Draft', 'weight' => -5, ], 'published' => [ 'label' => 'Published', 'weight' => 0, ], ], ], [ 'use simple_workflow transition publish' => [ 'title' => 'Use <em class="placeholder">Publish</em> transition from <em class="placeholder">Simple Workflow</em> workflow.', ], 'use simple_workflow transition unpublish' => [ 'title' => 'Use <em class="placeholder">Unpublish</em> transition from <em class="placeholder">Simple Workflow</em> workflow.', 'use simple_workflow transition create_new_draft' => [ 'title' => 'Use <em class="placeholder">Create New Draft</em> transition from <em class="placeholder">Simple Workflow</em> workflow.', ], ], ], Loading