You are here

public function MaestroSpawnSubFlowTask::prepareTaskForSave in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/EngineTasks/MaestroSpawnSubFlowTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroSpawnSubFlowTask::prepareTaskForSave()

The specific task's manipulation of the values to save for a template save.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form's form state.

array $task: The fully loaded task array from the template.

Overrides MaestroEngineTaskInterface::prepareTaskForSave

File

src/Plugin/EngineTasks/MaestroSpawnSubFlowTask.php, line 295

Class

MaestroSpawnSubFlowTask
Maestro Spawn Sub Flow Task Plugin.

Namespace

Drupal\maestro\Plugin\EngineTasks

Code

public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) {
  $task['data']['maestro_template'] = $form_state
    ->getValue('maestro_template');

  // Now handle the variables.
  unset($task['data']['variables']);
  $all_values = $form_state
    ->getValues();
  foreach ($all_values as $key => $var) {
    if (strpos($key, 'variable_') === 0) {

      // Starts with 'variable_',so we know this is our variables.
      $is_checked = $form_state
        ->getValue($key);
      if ($is_checked) {

        // Strip of "variable_".
        $varname = substr($key, 9);

        // Signal that it's checked.
        $task['data']['variables'][$varname] = 1;
      }
    }
  }
}