You are here

function maestro_webform_spv_fetch_submission_value in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 modules/maestro_webform/maestro_webform.module \maestro_webform_spv_fetch_submission_value()

Set Process Variable (SPV) function which uses the webform's unique identifier referenced in the Maestro "webforms" process variable to read a value from the webform submission and return it to the SPV task to set the process variable in the task.

The "webforms" process variable is set by the Maestro Webforms submission handler which sets a "submission:xxx" value in the "webforms" process variable (where "xxx" is the unique ID of the submission), or is set by the Maestro Webform Task Type's "Unique Identifier" setting when editing a Maestro Webform Task.

Parameters

string $uniqueWebformIdentifier: The webform's "Unique Identifier" as stored in the "webforms" process variable.

string $webformFieldMachineName: The webform field's machine name (listed as "KEY" in the webform builder) you wish to pull the value out of.

int $queueID: Provided by the executing SPV task -- the QueueID of the SPV task.

int $processID: Provided by the executing SPV task -- the ProcessID of the workflow running the SPV task.

File

modules/maestro_webform/maestro_webform.module, line 181
Contains maestro_webform.module.

Code

function maestro_webform_spv_fetch_submission_value($uniqueWebformIdentifier, $webformFieldMachineName, $queueID, $processID) {
  $returnValue = 'unset';

  // This is the submission we're eventually after.
  $sid = FALSE;
  $sid = MaestroEngine::getEntityIdentiferByUniqueID($processID, $uniqueWebformIdentifier);
  if ($sid) {
    $webform_submission = WebformSubmission::load($sid);
  }
  if ($webform_submission && array_key_exists($webformFieldMachineName, $webform_submission
    ->getData())) {
    $returnValue = $webform_submission
      ->getData()[$webformFieldMachineName];
  }

  // At this point, the submission's value OR 'unset' is in the $returnValue.
  return $returnValue;
}