Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / workflows / src / Form / WorkflowAddForm.php
index 56cbf699617659b53779af7a3038a6538633423a..19894691239b69d3c06c0c880afedeb55d14e3a0 100644 (file)
@@ -53,7 +53,6 @@ class WorkflowAddForm extends EntityForm {
       '#title' => $this->t('Label'),
       '#maxlength' => 255,
       '#default_value' => $workflow->label(),
-      '#description' => $this->t('Label for the Workflow.'),
       '#required' => TRUE,
     ];
 
@@ -65,9 +64,8 @@ class WorkflowAddForm extends EntityForm {
       ],
     ];
 
-    $workflow_types = array_map(function ($plugin_definition) {
-      return $plugin_definition['label'];
-    }, $this->workflowTypePluginManager->getDefinitions());
+    $workflow_types = array_column($this->workflowTypePluginManager->getDefinitions(), 'label', 'id');
+
     $form['workflow_type'] = [
       '#type' => 'select',
       '#title' => $this->t('Workflow type'),
@@ -84,10 +82,8 @@ class WorkflowAddForm extends EntityForm {
   public function save(array $form, FormStateInterface $form_state) {
     /* @var \Drupal\workflows\WorkflowInterface $workflow */
     $workflow = $this->entity;
-    // Initialize the workflow using the selected type plugin.
-    $workflow = $workflow->getTypePlugin()->initializeWorkflow($workflow);
     $return = $workflow->save();
-    if (empty($workflow->getStates())) {
+    if (empty($workflow->getTypePlugin()->getStates())) {
       drupal_set_message($this->t('Created the %label Workflow. In order for the workflow to be enabled there needs to be at least one state.', [
         '%label' => $workflow->label(),
       ]));