You are here

public static function MaestroEngine::saveTemplateTask in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Engine/MaestroEngine.php \Drupal\maestro\Engine\MaestroEngine::saveTemplateTask()

Saves/updates the task.

Parameters

string $templateMachineName: The machine name of the template the task belongs to.

string $taskMachineName: The machine name of the task itself.

array $task: The task array representation loaded from the template and augmented as you see fit.

1 call to MaestroEngine::saveTemplateTask()
MaestroTaskTrait::saveTask in src/MaestroTaskTrait.php
Available for all tasks -- this does the general task construction for us, ensuring we have sanity in the saved Config Entity for the task. Assignments and Notifications are the two main elements this method worries about.

File

src/Engine/MaestroEngine.php, line 208

Class

MaestroEngine
Class MaestroEngine.

Namespace

Drupal\maestro\Engine

Code

public static function saveTemplateTask($templateMachineName, $taskMachineName, array $task) {
  $returnValue = FALSE;
  $template = MaestroEngine::getTemplate($templateMachineName);
  $taskID = $task['id'];
  $template->tasks[$taskID] = $task;
  try {
    $returnValue = $template
      ->save();
  } catch (EntityStorageException $e) {

    // Something went wrong.  Catching it.  We will return FALSE to signify that it hasn't saved.
    $returnValue = FALSE;
  }
  return $returnValue;
}