You are here

public function WSCallTestForm::call in Web Service Data 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/WSCallTestForm.php \Drupal\wsdata\Form\WSCallTestForm::call()

Call the wscall.

File

src/Form/WSCallTestForm.php, line 83

Class

WSCallTestForm
Class WSCallForm.

Namespace

Drupal\wsdata\Form

Code

public function call(array $form, FormStateInterface $form_state) {
  $form_state
    ->setRebuild(TRUE);
  $form_state
    ->disableCache();
  $replacements = [];
  foreach ($this->entity
    ->getReplacements() as $replacement) {
    $replacements[$replacement] = $form_state
      ->getValue($replacement);
  }
  $response = $this->wsdata
    ->call($this->entity
    ->id(), NULL, $replacements, $form_state
    ->getValue('data'), [], $form_state
    ->getValue('returnToken'));
  $form_state
    ->setValue('wscall_response', is_array($response) ? print_r($response, TRUE) : $response);
}