diff --git a/core/modules/workflows/src/Form/WorkflowStateAddForm.php b/core/modules/workflows/src/Form/WorkflowStateAddForm.php index 1827dd3e89..7d714b2dfe 100644 --- a/core/modules/workflows/src/Form/WorkflowStateAddForm.php +++ b/core/modules/workflows/src/Form/WorkflowStateAddForm.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\workflows\WorkflowTypeFormInterface; /** * Class WorkflowStateAddForm. @@ -43,10 +44,13 @@ public function form(array $form, FormStateInterface $form_state) { ]; // Add additional form fields from the workflow type plugin. - $form['type_settings'] = [ - $workflow->get('type') => $workflow->getTypePlugin()->buildStateConfigurationForm($form_state, $workflow), - '#tree' => TRUE, - ]; + if ($workflow->getTypePlugin() instanceof WorkflowTypeFormInterface) { + $form['type_settings'] = [ + $workflow->get('type') => $workflow->getTypePlugin() + ->buildStateConfigurationForm($form_state, $workflow), + '#tree' => TRUE, + ]; + } return $form; } diff --git a/core/modules/workflows/src/Form/WorkflowStateEditForm.php b/core/modules/workflows/src/Form/WorkflowStateEditForm.php index f21508ff64..95e580144e 100644 --- a/core/modules/workflows/src/Form/WorkflowStateEditForm.php +++ b/core/modules/workflows/src/Form/WorkflowStateEditForm.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\workflows\WorkflowTypeFormInterface; /** * Class WorkflowStateEditForm. @@ -62,10 +63,13 @@ public function form(array $form, FormStateInterface $form_state) { ]; // Add additional form fields from the workflow type plugin. - $form['type_settings'] = [ - $workflow->get('type') => $workflow->getTypePlugin()->buildStateConfigurationForm($form_state, $workflow, $state), - '#tree' => TRUE, - ]; + if ($workflow->getTypePlugin() instanceof WorkflowTypeFormInterface) { + $form['type_settings'] = [ + $workflow->get('type') => $workflow->getTypePlugin() + ->buildStateConfigurationForm($form_state, $workflow, $state), + '#tree' => TRUE, + ]; + } $header = [ 'label' => $this->t('Transition'), diff --git a/core/modules/workflows/src/Form/WorkflowTransitionAddForm.php b/core/modules/workflows/src/Form/WorkflowTransitionAddForm.php index fe3a40636d..9ff55808ec 100644 --- a/core/modules/workflows/src/Form/WorkflowTransitionAddForm.php +++ b/core/modules/workflows/src/Form/WorkflowTransitionAddForm.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\workflows\State; +use Drupal\workflows\WorkflowTypeFormInterface; /** * Class WorkflowTransitionAddForm. @@ -62,10 +63,13 @@ public function form(array $form, FormStateInterface $form_state) { ]; // Add additional form fields from the workflow type plugin. - $form['type_settings'] = [ - $workflow->get('type') => $workflow->getTypePlugin()->buildTransitionConfigurationForm($form_state, $workflow), - '#tree' => TRUE, - ]; + if ($workflow->getTypePlugin() instanceof WorkflowTypeFormInterface) { + $form['type_settings'] = [ + $workflow->get('type') => $workflow->getTypePlugin() + ->buildTransitionConfigurationForm($form_state, $workflow), + '#tree' => TRUE, + ]; + } return $form; } diff --git a/core/modules/workflows/src/Form/WorkflowTransitionEditForm.php b/core/modules/workflows/src/Form/WorkflowTransitionEditForm.php index 5bbabae6f7..a737079a5b 100644 --- a/core/modules/workflows/src/Form/WorkflowTransitionEditForm.php +++ b/core/modules/workflows/src/Form/WorkflowTransitionEditForm.php @@ -7,6 +7,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\workflows\State; +use Drupal\workflows\WorkflowTypeFormInterface; /** * Class WorkflowTransitionEditForm. @@ -78,10 +79,13 @@ public function form(array $form, FormStateInterface $form_state) { ]; // Add additional form fields from the workflow type plugin. - $form['type_settings'] = [ - $workflow->get('type') => $workflow->getTypePlugin()->buildTransitionConfigurationForm($form_state, $workflow, $transition), - '#tree' => TRUE, - ]; + if ($workflow->getTypePlugin() instanceof WorkflowTypeFormInterface) { + $form['type_settings'] = [ + $workflow->get('type') => $workflow->getTypePlugin() + ->buildTransitionConfigurationForm($form_state, $workflow, $transition), + '#tree' => TRUE, + ]; + } return $form; } diff --git a/core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/TestType.php b/core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/TestType.php index 41007f0d80..6b35266485 100644 --- a/core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/TestType.php +++ b/core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/TestType.php @@ -3,7 +3,7 @@ namespace Drupal\workflow_type_test\Plugin\WorkflowType; use Drupal\Core\Form\FormStateInterface; -use Drupal\workflows\Plugin\WorkflowTypeFormBase; +use Drupal\workflows\Plugin\WorkflowTypeBase; /** * Test workflow type. @@ -13,7 +13,7 @@ * label = @Translation("Workflow Type Test"), * ) */ -class TestType extends WorkflowTypeFormBase { +class TestType extends WorkflowTypeBase { /** * {@inheritdoc} @@ -32,11 +32,4 @@ public function getRequiredStates() { return \Drupal::state()->get('workflow_type_test.required_states', []); } - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - return []; - } - }