You are here

public function MaestroOrchestrator::startProcess in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Controller/MaestroOrchestrator.php \Drupal\maestro\Controller\MaestroOrchestrator::startProcess()

Method used to start a process.

1 string reference to 'MaestroOrchestrator::startProcess'
maestro.routing.yml in ./maestro.routing.yml
maestro.routing.yml

File

src/Controller/MaestroOrchestrator.php, line 66

Class

MaestroOrchestrator
Maestro Orchestrator class.

Namespace

Drupal\maestro\Controller

Code

public function startProcess($templateMachineName = '', $redirect = 'taskconsole') {
  $template = MaestroEngine::getTemplate($templateMachineName);
  if ($template) {
    $engine = new MaestroEngine();
    $pid = $engine
      ->newProcess($templateMachineName);
    if ($pid) {
      \Drupal::messenger()
        ->addMessage(t('Process Started'));
      $config = $this
        ->config('maestro.settings');

      // Run the orchestrator for us once on process kickoff.
      $this
        ->orchestrate($config
        ->get('maestro_orchestrator_token'), TRUE);
    }
    else {
      \Drupal::messenger()
        ->addError(t('Error!  Process unable to start!'));
    }
  }
  else {
    \Drupal::messenger()
      ->addError(t('Error!  No template by that name exits!'));
  }
  if ($redirect == 'taskconsole') {
    return new RedirectResponse(Url::fromRoute('maestro_taskconsole.taskconsole')
      ->toString());
  }
  elseif ($redirect == 'templates') {
    return new RedirectResponse(Url::fromRoute('entity.maestro_template.list')
      ->toString());
  }
  else {
    return new RedirectResponse(Url::fromUserInput('/' . $redirect)
      ->toString());
  }
}