You are here

public function MaestroInteractiveExampleTask::prepareTaskForSave in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 modules/examples/maestro_interactive_task_plugin_example/src/Plugin/EngineTasks/MaestroInteractiveExampleTask.php \Drupal\maestro_interactive_task_plugin_example\Plugin\EngineTasks\MaestroInteractiveExampleTask::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

modules/examples/maestro_interactive_task_plugin_example/src/Plugin/EngineTasks/MaestroInteractiveExampleTask.php, line 209

Class

MaestroInteractiveExampleTask
Maestro Interactive Example Task Plugin.

Namespace

Drupal\maestro_interactive_task_plugin_example\Plugin\EngineTasks

Code

public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) {

  /*
   * Do you need to massage the edited and saved data in for this task before it is saved to the template?
   * This is where you do that.  Generally you'd place task data into the 'data' property of the template as shown
   * in the example here:
   *
   * $task['handler'] = $form_state->getValue('handler');  //if you have a handler field, this is how you'd populate the task with it
   * $task['data']['my_field'] = ...do some work here....;
   *
   */

  // We are forcing the handler, on save, to our stock accept task.
  // You can find this in the maestro.module file.
  $task['handler'] = 'maestro_accept_only_form';

  // Since this is an interactive task, it is up to you to either get a handler from the end user
  // OR force it to something specific.
  // we are also forcing down the modal option so that the task appears as a form.
  // Forcing this to be a modal task means that the $task['handler'] is assumed to be a Drupal Form.
  $task['data']['modal'] = 'modal';
}