diff --git a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php index 7e3d512..feb8e09 100644 --- a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +++ b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php @@ -214,6 +214,9 @@ public function calculateDependencies() { return []; } + /** + * {@inheritdoc} + */ public function editForm(WorkflowInterface $workflow) { $form['attachments'] = [ '#type' => 'details', @@ -243,6 +246,9 @@ public function editForm(WorkflowInterface $workflow) { return $form; } + /** + * {@inheritdoc} + */ public function editFormSave(WorkflowInterface &$workflow, array $form, FormStateInterface $formState) { foreach ($formState->getValues()['attachments'] as $entity_type_id => $bundle_ids) { foreach ($bundle_ids as $bundle_id => $checked) { diff --git a/core/modules/workflows/src/Form/WorkflowTypeSettings.php b/core/modules/workflows/src/Form/WorkflowTypeSettings.php new file mode 100644 index 0000000..f70ba53 --- /dev/null +++ b/core/modules/workflows/src/Form/WorkflowTypeSettings.php @@ -0,0 +1,46 @@ +entity; + $form += $workflow->getTypePlugin()->editForm($workflow); + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $workflow = $this->entity; + $workflow->getTypePlugin()->editFormSave($workflow, $form, $form_state); + parent::submitForm($form, $form_state); + } + + /** + * Title callback for the form. + */ + public static function formTitle(Workflow $workflow) { + return t('Edit %label settings', ['%label' => $workflow->label()]); + } + +} diff --git a/core/modules/workflows/workflows.links.task.yml b/core/modules/workflows/workflows.links.task.yml new file mode 100644 index 0000000..6c6df4a --- /dev/null +++ b/core/modules/workflows/workflows.links.task.yml @@ -0,0 +1,8 @@ +entity.workflow.edit: + title: 'Edit' + route_name: entity.workflow.edit_form + base_route: entity.workflow.edit_form +entity.workflow.type_settings_form: + title: 'Settings' + route_name: entity.workflow.type_settings_form + base_route: entity.workflow.edit_form diff --git a/core/modules/workflows/workflows.module b/core/modules/workflows/workflows.module index 26f72b4..54e0999 100644 --- a/core/modules/workflows/workflows.module +++ b/core/modules/workflows/workflows.module @@ -16,6 +16,7 @@ use Drupal\workflows\Form\WorkflowTransitionAddForm; use Drupal\workflows\Form\WorkflowTransitionEditForm; use Drupal\workflows\Form\WorkflowTransitionDeleteForm; +use Drupal\workflows\Form\WorkflowTypeSettings; use Drupal\workflows\WorkflowListBuilder; /** @@ -47,6 +48,7 @@ function workflows_entity_type_build(array &$entity_types) { ->setFormClass('add-transition', WorkflowTransitionAddForm::class) ->setFormClass('edit-transition', WorkflowTransitionEditForm::class) ->setFormClass('delete-transition', WorkflowTransitionDeleteForm::class) + ->setFormClass('type-settings', WorkflowTypeSettings::class) ->setListBuilderClass(WorkflowListBuilder::class) ->set('admin_permission', 'administer workflows') ->setLinkTemplate('add-form', '/admin/config/workflow/workflows/add') @@ -54,5 +56,6 @@ function workflows_entity_type_build(array &$entity_types) { ->setLinkTemplate('delete-form', '/admin/config/workflow/workflows/manage/{workflow}/delete') ->setLinkTemplate('add-state-form', '/admin/config/workflow/workflows/manage/{workflow}/add_state') ->setLinkTemplate('add-transition-form', '/admin/config/workflow/workflows/manage/{workflow}/add_transition') + ->setLinkTemplate('type-settings-form', '/admin/config/workflow/workflows/manage/{workflow}/type-settings') ->setLinkTemplate('collection', '/admin/config/workflow/workflows'); } diff --git a/core/modules/workflows/workflows.routing.yml b/core/modules/workflows/workflows.routing.yml index 377e572..a3aeb80 100644 --- a/core/modules/workflows/workflows.routing.yml +++ b/core/modules/workflows/workflows.routing.yml @@ -45,3 +45,11 @@ entity.workflow.delete_transition_form: _title: 'Delete transition' requirements: _entity_access: 'workflow.edit' + +entity.workflow.type_settings_form: + path: '/admin/config/workflow/workflows/manage/{workflow}/type-settings' + defaults: + _entity_form: 'workflow.type-settings' + _title_callback: '\Drupal\workflows\Form\WorkflowTypeSettings::formTitle' + requirements: + _entity_access: 'workflow.edit'