You are here

public function MaestroTemplateBuilderForm::drawLineTo in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 modules/maestro_template_builder/src/Form/MaestroTemplateBuilderForm.php \Drupal\maestro_template_builder\Form\MaestroTemplateBuilderForm::drawLineTo()

Ajax callback to signal the UI to go into line drawing mode.

File

modules/maestro_template_builder/src/Form/MaestroTemplateBuilderForm.php, line 107

Class

MaestroTemplateBuilderForm

Namespace

Drupal\maestro_template_builder\Form

Code

public function drawLineTo(array &$form, FormStateInterface $form_state) {
  $taskFrom = $form_state
    ->getValue('task_clicked');
  $templateMachineName = $form_state
    ->getValue('template_machine_name');
  $template = MaestroEngine::getTemplate($templateMachineName);
  $task = MaestroEngine::getTemplateTaskByID($templateMachineName, $taskFrom);
  if ($task['tasktype'] == 'MaestroEnd') {
    $response = new AjaxResponse();
    $response
      ->addCommand(new FireJavascriptCommand('maestroSignalError', [
      'message' => t('You are not able to draw a line FROM an end task!'),
    ]));
    return $response;
  }
  $response = new AjaxResponse();
  $response
    ->addCommand(new FireJavascriptCommand('maestroDrawLineTo', [
    'taskid' => $taskFrom,
  ]));
  $response
    ->addCommand(new FireJavascriptCommand('maestroCloseTaskMenu', []));
  return $response;
}