You are here

public function MaestroWebformHandler::submitForm in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 modules/maestro_webform/src/Plugin/WebformHandler/MaestroWebformHandler.php \Drupal\maestro_webform\Plugin\WebformHandler\MaestroWebformHandler::submitForm()

Submit webform submission form.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

Overrides WebformHandlerBase::submitForm

File

modules/maestro_webform/src/Plugin/WebformHandler/MaestroWebformHandler.php, line 181

Class

MaestroWebformHandler
Launches a Maestro workflow with a Webform submission.

Namespace

Drupal\maestro_webform\Plugin\WebformHandler

Code

public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

  // If we have maestro elements in the URL, we know that this is a submission that is as a result of
  // the task being INSIDE of a workflow and not spawned by itself.
  // If we can bind to a template task based on the maestro elements, then we will
  // set a webform submission data value signalling NOT to do any post-save actions if the task
  // has it's webform submission handler option checked off.
  // Make sure the key exists and default to not checked.
  $webform_submission->data['maestro_skip'] = FALSE;
  $maestroElements = $form_state
    ->getValue('maestro');
  if ($maestroElements) {
    $queueID = $maestroElements['queue_id'];
    $templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID);
    if ($templateTask) {

      // $webform_submission->setElementData('maestro_skip', $templateTask['data']['skip_webform_handlers']);
      $webform_submission->data['maestro_skip'] = $templateTask['data']['skip_webform_handlers'];
    }
  }
}