View source
<?php
namespace Drupal\maestro\Form;
use Drupal\Core\Form\FormStateInterface;
class MaestroTemplateAddForm extends MaestroTemplateFormBase {
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = $this
->t('Create Template');
return $actions;
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['description'] = [
'#markup' => $this
->t("Add a Maestro Template Definition"),
];
$form = parent::buildForm($form, $form_state);
return $form;
}
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
$this->entity->tasks['start'] = [
'id' => 'start',
'tasktype' => 'MaestroStart',
'label' => 'Start',
'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',
];
$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',
],
];
$this->entity->variables['initiator'] = [
'variable_id' => 'initiator',
'variable_value' => '0',
];
$this->entity->variables['workflow_timeline_stage_count'] = [
'variable_id' => 'workflow_timeline_stage_count',
'variable_value' => '',
];
$this->entity->variables['workflow_current_stage'] = [
'variable_id' => 'workflow_current_stage',
'variable_value' => '',
];
$this->entity->variables['workflow_current_stage_message'] = [
'variable_id' => 'workflow_current_stage_message',
'variable_value' => '',
];
$this->entity->validated = FALSE;
$this->entity
->save();
}
}