public function MaestroSpawnSubFlowTask::prepareTaskForSave in Maestro 3.x
Same name and namespace in other branches
- 8.2 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\EngineTasksCode
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;
}
}
}
}