You are here

protected function RemotePostYamlFormHandler::getPostData in YAML Form 8

Get a form submission's post data.

Parameters

string $operation: The type of form submission operation to be posted. Can be 'insert', 'update', or 'delete'.

\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: The form submission to be posted.

Return value

array A form submission converted to an associative array.

1 call to RemotePostYamlFormHandler::getPostData()
RemotePostYamlFormHandler::remotePost in src/Plugin/YamlFormHandler/RemotePostYamlFormHandler.php
Execute a remote post.

File

src/Plugin/YamlFormHandler/RemotePostYamlFormHandler.php, line 325

Class

RemotePostYamlFormHandler
Form submission remote post handler.

Namespace

Drupal\yamlform\Plugin\YamlFormHandler

Code

protected function getPostData($operation, YamlFormSubmissionInterface $yamlform_submission) {

  // Get submission and elements data.
  $data = $yamlform_submission
    ->toArray(TRUE);

  // Flatten data.
  // Prioritizing elements before the submissions fields.
  $data = $data['data'] + $data;
  unset($data['data']);

  // Excluded selected submission data.
  $data = array_diff_key($data, $this->configuration['excluded_data']);

  // Append custom data.
  if (!empty($this->configuration['custom_data'])) {
    $data = Yaml::decode($this->configuration['custom_data']) + $data;
  }

  // Append operation data.
  if (!empty($this->configuration[$operation . '_custom_data'])) {
    $data = Yaml::decode($this->configuration[$operation . '_custom_data']) + $data;
  }

  // Replace tokens.
  $data = $this->tokenManager
    ->replace($data, $yamlform_submission);
  return $data;
}