You are here

public function MaestroTemplateAddForm::save in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/MaestroTemplateAddForm.php \Drupal\maestro\Form\MaestroTemplateAddForm::save()

Overrides MaestroTemplateFormBase::save.

Overrides MaestroTemplateFormBase::save

File

src/Form/MaestroTemplateAddForm.php, line 50

Class

MaestroTemplateAddForm
Class MaestroTemplateAddForm.

Namespace

Drupal\maestro\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  parent::save($form, $form_state);

  // In here, we now create the basis for the template tasks.
  $this->entity->tasks['start'] = [
    'id' => 'start',
    'tasktype' => 'MaestroStart',
    'label' => 'Start',
    // Just for starters, the start points directly to the end task.
    'nextstep' => 'end',
    'nextfalsestep' => '',
    'top' => 50,
    'left' => 50,
    'assignby' => 'fixed',
    'assignto' => 'engine',
  ];
  $this->entity->tasks['end'] = [
    'id' => 'end',
    'tasktype' => 'MaestroEnd',
    'label' => 'End',
    'nextstep' => '',
    'nextfalsestep' => '',
    'top' => 200,
    'left' => 200,
    'assignby' => 'fixed',
    'assignto' => 'engine',
  ];

  // Add the two default views.
  $this->entity->views_attached = [
    'maestro_completed_tasks' => [
      'view_machine_name' => 'maestro_completed_tasks',
      'view_weight' => -9,
      'view_display' => 'default;Master',
    ],
    'maestro_entity_identifiers' => [
      'view_machine_name' => 'maestro_entity_identifiers',
      'view_weight' => -10,
      'view_display' => 'taskconsole_display;Task Console Display',
    ],
  ];

  // Add the initiator variable.
  $this->entity->variables['initiator'] = [
    'variable_id' => 'initiator',
    'variable_value' => '0',
  ];

  // Add the workflow_timeline_stage_count variable.
  $this->entity->variables['workflow_timeline_stage_count'] = [
    'variable_id' => 'workflow_timeline_stage_count',
    'variable_value' => '',
  ];

  // Add the workflow_current_stage variable.
  $this->entity->variables['workflow_current_stage'] = [
    'variable_id' => 'workflow_current_stage',
    'variable_value' => '',
  ];

  // Add the workflow_current_stage_message variable.
  $this->entity->variables['workflow_current_stage_message'] = [
    'variable_id' => 'workflow_current_stage_message',
    'variable_value' => '',
  ];
  $this->entity->validated = FALSE;
  $this->entity
    ->save();
}