diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module index 7345e93..7260eab 100644 --- a/core/modules/content_moderation/content_moderation.module +++ b/core/modules/content_moderation/content_moderation.module @@ -64,15 +64,6 @@ function content_moderation_entity_type_alter(array &$entity_types) { } /** - * Implements hook_entity_operation(). - */ -function content_moderation_entity_operation(EntityInterface $entity) { - return \Drupal::service('class_resolver') - ->getInstanceFromDefinition(EntityTypeInfo::class) - ->entityOperation($entity); -} - -/** * Implements hook_entity_presave(). */ function content_moderation_entity_presave(EntityInterface $entity) { diff --git a/core/modules/content_moderation/src/EntityTypeInfo.php b/core/modules/content_moderation/src/EntityTypeInfo.php index f11e471..1ccfbf5 100644 --- a/core/modules/content_moderation/src/EntityTypeInfo.php +++ b/core/modules/content_moderation/src/EntityTypeInfo.php @@ -21,9 +21,7 @@ use Drupal\content_moderation\Entity\Handler\BlockContentModerationHandler; use Drupal\content_moderation\Entity\Handler\ModerationHandler; use Drupal\content_moderation\Entity\Handler\NodeModerationHandler; -use Drupal\content_moderation\Form\BundleModerationConfigurationForm; use Drupal\content_moderation\Routing\EntityModerationRouteProvider; -use Drupal\content_moderation\Routing\EntityTypeModerationRouteProvider; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -127,11 +125,6 @@ public function entityTypeAlter(array &$entity_types) { // The ContentModerationState entity type should never be moderated. if ($entity_type->isRevisionable() && $entity_type_id != 'content_moderation_state') { $entity_types[$entity_type_id] = $this->addModerationToEntityType($entity_type); - // Add additional moderation support to entity types whose bundles are - // managed by a config entity type. - if ($entity_type->getBundleEntityType()) { - $entity_types[$entity_type->getBundleEntityType()] = $this->addModerationToBundleEntityType($entity_types[$entity_type->getBundleEntityType()]); - } } } } @@ -170,67 +163,6 @@ protected function addModerationToEntityType(ContentEntityTypeInterface $type) { } /** - * Configures moderation configuration support on a entity type definition. - * - * That "configuration support" includes a configuration form, a hypermedia - * link, and a route provider to tie it all together. There's also a - * moderation handler for per-entity-type variation. - * - * @param \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $type - * The config entity definition to modify. - * - * @return \Drupal\Core\Config\Entity\ConfigEntityTypeInterface - * The modified config entity definition. - */ - protected function addModerationToBundleEntityType(ConfigEntityTypeInterface $type) { - if ($type->hasLinkTemplate('edit-form') && !$type->hasLinkTemplate('moderation-form')) { - $type->setLinkTemplate('moderation-form', $type->getLinkTemplate('edit-form') . '/moderation'); - } - - if (!$type->getFormClass('moderation')) { - $type->setFormClass('moderation', BundleModerationConfigurationForm::class); - } - - // @todo Core forgot to add a direct way to manipulate route_provider, so - // we have to do it the sloppy way for now. - $providers = $type->getRouteProviderClasses() ?: []; - if (empty($providers['moderation'])) { - $providers['moderation'] = EntityTypeModerationRouteProvider::class; - $type->setHandlerClass('route_provider', $providers); - } - - return $type; - } - - /** - * Adds an operation on bundles that should have a Moderation form. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity on which to define an operation. - * - * @return array - * An array of operation definitions. - * - * @see hook_entity_operation() - */ - public function entityOperation(EntityInterface $entity) { - $operations = []; - $type = $entity->getEntityType(); - $bundle_of = $type->getBundleOf(); - if ($this->currentUser->hasPermission('administer content moderation') && $bundle_of && - $this->moderationInfo->canModerateEntitiesOfEntityType($this->entityTypeManager->getDefinition($bundle_of)) - ) { - $operations['manage-moderation'] = [ - 'title' => t('Manage moderation'), - 'weight' => 27, - 'url' => Url::fromRoute("entity.{$type->id()}.moderation", [$entity->getEntityTypeId() => $entity->id()]), - ]; - } - - return $operations; - } - - /** * Gets the "extra fields" for a bundle. * * This is a hook bridge. diff --git a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php deleted file mode 100644 index 917ec5d..0000000 --- a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php +++ /dev/null @@ -1,155 +0,0 @@ -entityTypeManager = $entity_type_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('entity_type.manager')); - } - - /** - * {@inheritdoc} - * - * Blank out the base form ID so that form alters that use the base form ID to - * target both add and edit forms don't pick up this form. - */ - public function getBaseFormId() { - return NULL; - } - - /** - * {@inheritdoc} - */ - public function form(array $form, FormStateInterface $form_state) { - /* @var \Drupal\Core\Config\Entity\ConfigEntityInterface $bundle */ - $bundle = $this->getEntity(); - $bundle_of_entity_type = $this->entityTypeManager->getDefinition($bundle->getEntityType()->getBundleOf()); - /* @var \Drupal\workflows\WorkflowInterface[] $workflows */ - $workflows = $this->entityTypeManager->getStorage('workflow')->loadMultiple(); - - $options = array_map(function (WorkflowInterface $workflow) { - return $workflow->label(); - }, array_filter($workflows, function (WorkflowInterface $workflow) { - return $workflow->status() && $workflow->getTypePlugin() instanceof ContentModeration; - })); - - $selected_workflow = array_reduce($workflows, function ($carry, WorkflowInterface $workflow) use ($bundle_of_entity_type, $bundle) { - $plugin = $workflow->getTypePlugin(); - if ($plugin instanceof ContentModeration && $plugin->appliesToEntityTypeAndBundle($bundle_of_entity_type->id(), $bundle->id())) { - return $workflow->id(); - } - return $carry; - }); - $form['workflow'] = [ - '#type' => 'select', - '#title' => $this->t('Select the workflow to apply'), - '#default_value' => $selected_workflow, - '#options' => $options, - '#required' => FALSE, - '#empty_value' => '', - ]; - - $form['original_workflow'] = [ - '#type' => 'value', - '#value' => $selected_workflow, - ]; - - $form['bundle'] = [ - '#type' => 'value', - '#value' => $bundle->id(), - ]; - - $form['entity_type'] = [ - '#type' => 'value', - '#value' => $bundle_of_entity_type->id(), - ]; - - // Add a special message when moderation is being disabled. - if ($selected_workflow) { - $form['enable_workflow_note'] = [ - '#type' => 'item', - '#description' => $this->t('After disabling moderation, any existing forward drafts will be accessible via the "Revisions" tab.'), - '#access' => !empty($selected_workflow) - ]; - } - - return parent::form($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - // If moderation is enabled, revisions MUST be enabled as well. Otherwise we - // can't have forward revisions. - drupal_set_message($this->t('Your settings have been saved.')); - } - - /** - * {@inheritdoc} - */ - public function save(array $form, FormStateInterface $form_state) { - $entity_type_id = $form_state->getValue('entity_type'); - $bundle_id = $form_state->getValue('bundle'); - $new_workflow_id = $form_state->getValue('workflow'); - $original_workflow_id = $form_state->getValue('original_workflow'); - if ($new_workflow_id === $original_workflow_id) { - // Nothing to do. - return; - } - if ($original_workflow_id) { - /* @var \Drupal\workflows\WorkflowInterface $workflow */ - $workflow = $this->entityTypeManager->getStorage('workflow')->load($original_workflow_id); - $workflow->getTypePlugin()->removeEntityTypeAndBundle($entity_type_id, $bundle_id); - $workflow->save(); - } - if ($new_workflow_id) { - /* @var \Drupal\workflows\WorkflowInterface $workflow */ - $workflow = $this->entityTypeManager->getStorage('workflow')->load($new_workflow_id); - $workflow->getTypePlugin()->addEntityTypeAndBundle($entity_type_id, $bundle_id); - $workflow->save(); - } - } - - /** - * {@inheritdoc} - */ - protected function actions(array $form, FormStateInterface $form_state) { - $actions['submit'] = [ - '#type' => 'submit', - '#value' => $this->t('Save'), - '#submit' => ['::submitForm', '::save'], - ]; - - return $actions; - } - -} diff --git a/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php b/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php index 7ff1fa5..9f09a9a 100644 --- a/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php +++ b/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php @@ -76,19 +76,6 @@ public static function create(ContainerInterface $container, $base_plugin_id) { public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = []; - foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { - if ($this->moderationInfo->canModerateEntitiesOfEntityType($entity_type)) { - $bundle_id = $entity_type->getBundleEntityType(); - $this->derivatives["$bundle_id.moderation_tab"] = [ - 'route_name' => "entity.$bundle_id.moderation", - 'title' => $this->t('Manage moderation'), - // @todo - are we sure they all have an edit_form? - 'base_route' => "entity.$bundle_id.edit_form", - 'weight' => 30, - ] + $base_plugin_definition; - } - } - $latest_version_entities = array_filter($this->entityTypeManager->getDefinitions(), function (EntityTypeInterface $type) { return $this->moderationInfo->canModerateEntitiesOfEntityType($type) && $type->hasLinkTemplate('latest-version'); }); diff --git a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php index e61f25e..ec37dd3 100644 --- a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +++ b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php @@ -2,14 +2,18 @@ namespace Drupal\content_moderation\Plugin\WorkflowType; +use Drupal\content_moderation\ModerationInformationInterface; use Drupal\Core\Access\AccessResult; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\content_moderation\ContentModerationState; use Drupal\workflows\Plugin\WorkflowTypeBase; use Drupal\workflows\StateInterface; use Drupal\workflows\WorkflowInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Attaches workflows to content entity types and their bundles. @@ -19,11 +23,58 @@ * label = @Translation("Content moderation"), * ) */ -class ContentModeration extends WorkflowTypeBase { +class ContentModeration extends WorkflowTypeBase implements ContainerFactoryPluginInterface { use StringTranslationTrait; /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The moderation information service. + * + * @var \Drupal\content_moderation\ModerationInformationInterface + */ + protected $moderationInfo; + + /** + * Constructs an ContentModeration object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. + * @param \Drupal\content_moderation\ModerationInformationInterface $moderation_info + * Moderation information service. + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModerationInformationInterface $moderation_info) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->entityTypeManager = $entity_type_manager; + $this->moderationInfo = $moderation_info; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager'), + $container->get('content_moderation.moderation_information') + ); + } + + /** * {@inheritdoc} */ public function checkWorkflowAccess(WorkflowInterface $entity, $operation, AccountInterface $account) { @@ -145,7 +196,7 @@ public function addEntityTypeAndBundle($entity_type_id, $bundle_id) { } /** - * {@inheritDoc} + * {@inheritdoc} */ public function defaultConfiguration() { // This plugin does not store anything per transition. @@ -156,11 +207,66 @@ public function defaultConfiguration() { } /** - * @inheritDoc + * {@inheritdoc} */ public function calculateDependencies() { // @todo : Implement calculateDependencies() method. return []; } + /** + * {@inheritdoc} + */ + public function editForm(WorkflowInterface $workflow) { + $form['attachments'] = [ + '#type' => 'details', + '#title' => $this->t('Select types to use this workflow'), + '#open' => TRUE, + '#tree' => TRUE, + ]; + + $entity_types = $this->entityTypeManager->getDefinitions(); + foreach ($entity_types as $entity_type) { + if ($this->moderationInfo->canModerateEntitiesOfEntityType($entity_type)) { + $options = []; + $defaults = []; + $bundles = $this->entityTypeManager->getStorage($entity_type->getBundleEntityType())->loadMultiple(); + foreach ($bundles as $bundle) { + if (!$this->moderationInfo->shouldModerateEntitiesOfBundle($entity_type, $bundle->id()) || $this->appliesToEntityTypeAndBundle($entity_type->id(), $bundle->id())) { + $options[$bundle->id()] = $bundle->label(); + $defaults[$bundle->id()] = $this->appliesToEntityTypeAndBundle($entity_type->id(), $bundle->id()); + } + } + + if (!empty($options)) { + $form['attachments'][$entity_type->id()] = [ + '#type' => 'checkboxes', + '#title' => $entity_type->getLabel()->render(), + '#options' => $options, + '#default_value' => array_keys(array_filter($defaults)), + ]; + } + } + } + + return $form; + } + + /** + * {@inheritdoc} + */ + public function editFormSave(WorkflowInterface &$workflow, array $form, FormStateInterface $formState) { + $type_plugin = $workflow->getTypePlugin(); + foreach ($formState->getValues()['attachments'] as $entity_type_id => $bundle_ids) { + foreach ($bundle_ids as $bundle_id => $checked) { + if ($checked) { + $type_plugin->addEntityTypeAndBundle($entity_type_id, $bundle_id); + } + else { + $type_plugin->removeEntityTypeAndBundle($entity_type_id, $bundle_id); + } + } + } + } + } diff --git a/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php b/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php deleted file mode 100644 index d1dcd2b..0000000 --- a/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php +++ /dev/null @@ -1,59 +0,0 @@ -getModerationFormRoute($entity_type)) { - $entity_type_id = $entity_type->id(); - $collection->add("entity.{$entity_type_id}.moderation", $moderation_route); - } - - return $collection; - } - - /** - * Gets the moderation-form route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getModerationFormRoute(EntityTypeInterface $entity_type) { - if ($entity_type->hasLinkTemplate('moderation-form') && $entity_type->getFormClass('moderation')) { - $entity_type_id = $entity_type->id(); - - $route = new Route($entity_type->getLinkTemplate('moderation-form')); - - // @todo Come up with a new permission. - $route - ->setDefaults([ - '_entity_form' => "{$entity_type_id}.moderation", - '_title' => 'Moderation', - ]) - ->setRequirement('_permission', 'administer content moderation') - ->setOption('parameters', [ - $entity_type_id => ['type' => 'entity:' . $entity_type_id], - ]); - - return $route; - } - } - -} diff --git a/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php b/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php index e42f536..faf6934 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php @@ -51,17 +51,10 @@ protected function setUp() { public function testCustomBlockModeration() { $this->drupalLogin($this->rootUser); - $this->drupalGet('admin/structure/block/block-content/types'); - $this->assertLinkByHref('admin/structure/block/block-content/manage/basic/moderation'); - $this->drupalGet('admin/structure/block/block-content/manage/basic'); - $this->assertLinkByHref('admin/structure/block/block-content/manage/basic/moderation'); - $this->drupalGet('admin/structure/block/block-content/manage/basic/moderation'); - - // Enable moderation for custom blocks at - // admin/structure/block/block-content/manage/basic/moderation. - $edit = ['workflow' => 'editorial']; - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('Your settings have been saved.')); + // Enable moderation for custom blocks. + $edit['attachments[block_content][basic]'] = TRUE; + $this->drupalPostForm('admin/config/workflow/workflows/manage/editorial', $edit, t('Save')); + $this->assertText(t('Saved the Editorial workflow Workflow.')); // Create a custom block at block/add and save it as draft. $body = 'Body of moderated block'; diff --git a/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php b/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php index a89ec9f..fe033bc 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php @@ -53,9 +53,8 @@ public function testCreatingContent() { $this->assertText(t('The Moderated content moderated content has been deleted.')); // Disable content moderation. - $this->drupalPostForm('admin/structure/types/manage/moderated_content/moderation', ['workflow' => ''], t('Save')); - $this->drupalGet('admin/structure/types/manage/moderated_content/moderation'); - $this->assertOptionSelected('edit-workflow', ''); + $edit['attachments[node][moderated_content]'] = FALSE; + $this->drupalPostForm('admin/config/workflow/workflows/manage/editorial', $edit, t('Save'));; // Ensure the parent environment is up-to-date. // @see content_moderation_workflow_insert() \Drupal::service('entity_type.bundle.info')->clearCachedBundles(); @@ -71,21 +70,6 @@ public function testCreatingContent() { $this->fail('Non-moderated test node was not saved correctly.'); } $this->assertEqual(NULL, $node->moderation_state->value); - - // \Drupal\content_moderation\Form\BundleModerationConfigurationForm() - // should not list workflows with no states. - $workflow = Workflow::create(['id' => 'stateless', 'label' => 'Stateless', 'type' => 'content_moderation']); - $workflow->save(); - - $this->drupalGet('admin/structure/types/manage/moderated_content/moderation'); - $this->assertNoText('Stateless'); - $workflow - ->addState('draft', 'Draft') - ->addState('published', 'Published') - ->addTransition('publish', 'Publish', ['draft', 'published'], 'published') - ->save(); - $this->drupalGet('admin/structure/types/manage/moderated_content/moderation'); - $this->assertText('Stateless'); } /** diff --git a/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php index 099b4dc..e752c65 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php @@ -42,17 +42,8 @@ public function testEnablingOnExistingContent() { ], t('Save and publish')); $this->assertText('Not moderated Test has been created.'); - // Now enable moderation state, ensuring all the expected links and tabs are - // present. - $this->drupalGet('admin/structure/types'); - $this->assertLinkByHref('admin/structure/types/manage/not_moderated/moderation'); - $this->drupalGet('admin/structure/types/manage/not_moderated'); - $this->assertLinkByHref('admin/structure/types/manage/not_moderated/moderation'); - $this->drupalGet('admin/structure/types/manage/not_moderated/moderation'); - $this->assertOptionSelected('edit-workflow', ''); - $this->assertNoLink('Delete'); - $edit['workflow'] = 'editorial'; - $this->drupalPostForm(NULL, $edit, t('Save')); + // Now enable moderation state. + $this->enableModerationThroughUi('not_moderated'); // And make sure it works. $nodes = \Drupal::entityTypeManager()->getStorage('node') diff --git a/core/modules/content_moderation/src/Tests/ModerationStateTestBase.php b/core/modules/content_moderation/src/Tests/ModerationStateTestBase.php index 22307df..0765fb6 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateTestBase.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateTestBase.php @@ -38,6 +38,7 @@ 'access content overview', 'use editorial transition create_new_draft', 'use editorial transition publish', + 'administer workflows', ]; /** @@ -112,9 +113,11 @@ protected function createContentTypeFromUi($content_type_name, $content_type_id, * @param string $workflow_id * The workflow to attach to the bundle. */ - protected function enableModerationThroughUi($content_type_id, $workflow_id = 'editorial') { - $edit['workflow'] = $workflow_id; - $this->drupalPostForm('admin/structure/types/manage/' . $content_type_id . '/moderation', $edit, t('Save')); + public function enableModerationThroughUi($content_type_id, $workflow_id = 'editorial') { + $this->drupalGet('/admin/config/workflow/workflows'); + $this->assertLinkByHref('admin/config/workflow/workflows/manage/' . $workflow_id); + $edit['attachments[node][' . $content_type_id . ']'] = TRUE; + $this->drupalPostForm('admin/config/workflow/workflows/manage/' . $workflow_id, $edit, t('Save')); // Ensure the parent environment is up-to-date. // @see content_moderation_workflow_insert() \Drupal::service('entity_type.bundle.info')->clearCachedBundles(); diff --git a/core/modules/workflows/src/Form/WorkflowEditForm.php b/core/modules/workflows/src/Form/WorkflowEditForm.php index d8f99f9..8d2e398 100644 --- a/core/modules/workflows/src/Form/WorkflowEditForm.php +++ b/core/modules/workflows/src/Form/WorkflowEditForm.php @@ -179,6 +179,8 @@ public function form(array $form, FormStateInterface $form_state) { '#markup' => $workflow->toLink($this->t('Add a new transition'), 'add-transition-form')->toString(), ]; + $form += $workflow->getTypePlugin()->editForm($workflow); + return $form; } @@ -188,6 +190,7 @@ public function form(array $form, FormStateInterface $form_state) { public function save(array $form, FormStateInterface $form_state) { /* @var \Drupal\workflows\WorkflowInterface $workflow */ $workflow = $this->entity; + $workflow->getTypePlugin()->editFormSave($workflow, $form, $form_state); $workflow->save(); drupal_set_message($this->t('Saved the %label Workflow.', ['%label' => $workflow->label()])); $form_state->setRedirectUrl($workflow->toUrl('collection')); diff --git a/core/modules/workflows/src/Plugin/WorkflowTypeBase.php b/core/modules/workflows/src/Plugin/WorkflowTypeBase.php index 1ed9fca..7f9462f 100644 --- a/core/modules/workflows/src/Plugin/WorkflowTypeBase.php +++ b/core/modules/workflows/src/Plugin/WorkflowTypeBase.php @@ -49,28 +49,28 @@ public function checkWorkflowAccess(WorkflowInterface $entity, $operation, Accou } /** - * {@inheritDoc} + * {@inheritdoc} */ public function decorateState(StateInterface $state) { return $state; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function deleteState($state_id) { unset($this->configuration['states'][$state_id]); } /** - * {@inheritDoc} + * {@inheritdoc} */ public function decorateTransition(TransitionInterface $transition) { return $transition; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function deleteTransition($transition_id) { unset($this->configuration['transitions'][$transition_id]); @@ -91,14 +91,14 @@ public function buildTransitionConfigurationForm(FormStateInterface $form_state, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getConfiguration() { return $this->configuration; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function setConfiguration(array $configuration) { $this->configuration = NestedArray::mergeDeep( @@ -108,7 +108,7 @@ public function setConfiguration(array $configuration) { } /** - * {@inheritDoc} + * {@inheritdoc} */ public function defaultConfiguration() { return [ @@ -118,10 +118,24 @@ public function defaultConfiguration() { } /** - * {@inheritDoc} + * {@inheritdoc} */ public function calculateDependencies() { return []; } + /** + * {@inheritdoc} + */ + public function editForm(WorkflowInterface $workflow) { + return []; + } + + /** + * {@inheritdoc} + */ + public function editFormSave(WorkflowInterface &$workflow, array $form, FormStateInterface $form_state) { + + } + } diff --git a/core/modules/workflows/src/WorkflowTypeInterface.php b/core/modules/workflows/src/WorkflowTypeInterface.php index 17fddec..287e672 100644 --- a/core/modules/workflows/src/WorkflowTypeInterface.php +++ b/core/modules/workflows/src/WorkflowTypeInterface.php @@ -117,4 +117,29 @@ public function buildStateConfigurationForm(FormStateInterface $form_state, Work */ public function buildTransitionConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, TransitionInterface $transition = NULL); + /** + * Returns a form array to append to the Workflow entity edit form. + * + * @param \Drupal\workflows\WorkflowInterface $workflow + * The workflow the form will be added to. + * + * @return array + * A form array to be used for type specific workflow settings. + * + * @see \Drupal\workflows\Form\WorkflowTransitionEditForm::form() + */ + public function editForm(WorkflowInterface $workflow); + + /** + * Save workflow type specific settings. + * + * @param \Drupal\workflows\WorkflowInterface $workflow + * The workflow the submitting form was added to. + * @param array $form + * The form array that was submitted. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The form state for the submitted form. + */ + public function editFormSave(WorkflowInterface &$workflow, array $form, FormStateInterface $form_state); + }