You are here

public function MaestroInteractiveExampleTask::getExecutableForm in Maestro 8.2

Same name and namespace in other branches
  1. 3.x modules/examples/maestro_interactive_task_plugin_example/src/Plugin/EngineTasks/MaestroInteractiveExampleTask.php \Drupal\maestro_interactive_task_plugin_example\Plugin\EngineTasks\MaestroInteractiveExampleTask::getExecutableForm()

Gets the Maestro executable form for a task console.

Parameters

string $modal: Defines if the form is a modal form or not.

Drupal\maestro\Form\MaestroExecuteInteractive $parent: Parent class for using modal callbacks to the interactive form base if needed.

Return value

array Array Must return form declaration fields if this task is interactive or not.

Overrides MaestroEngineTaskInterface::getExecutableForm

File

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

Class

MaestroInteractiveExampleTask
Maestro Interactive Example Task Plugin.

Namespace

Drupal\maestro_interactive_task_plugin_example\Plugin\EngineTasks

Code

public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {

  /*
   * For the built in MaestroInteractiveTask, this method will only ever be called if the 'handler' template property is not set.
   *
   * This task has been set to be a non-interactive task, however, we'll just plunk in a form as an example.
   *
   * We use the MaestroExecuteInterative class which extends the MaestroInteractiveFormBase class in order to provide
   * a slew of features and functionality to allow for a complete execution of an interactive task.
   */
  $form['queueID'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('The queue ID of this task'),
    '#default_value' => $this->queueID,
    '#description' => $this
      ->t('queueID'),
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Accept'),
  ];
  $form['actions']['reject'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Reject'),
  ];

  // If this is a modal task, we use the ajax completion routines and tell the buttons to use our built in completeForm modal closer.
  if ($modal == 'modal') {
    $form['actions']['submit']['#ajax'] = [
      // You will find this in the MaestroInteractiveFormBase.php file.
      'callback' => [
        $parent,
        'completeForm',
      ],
      'wrapper' => '',
    ];
    $form['actions']['reject']['#ajax'] = [
      // You will find this in the MaestroInteractiveFormBase.php file.
      'callback' => [
        $parent,
        'completeForm',
      ],
      'wrapper' => '',
    ];
  }
  return $form;
}