You are here

public function WSDataService::call in Web Service Data 8

Same name and namespace in other branches
  1. 2.0.x src/WSDataService.php \Drupal\wsdata\WSDataService::call()

Call method to make the WSCall.

File

src/WSDataService.php, line 68

Class

WSDataService
Service for processing WSData requests.

Namespace

Drupal\wsdata

Code

public function call($wscall, $method = NULL, $replacements = [], $data = NULL, $options = [], $key = NULL, $tokens = [], $cache_tag = []) {
  $this->status = [];
  if (!is_object($wscall)) {
    $wscall = $this->entity_type_manager
      ->getStorage('wscall')
      ->load($wscall);
  }
  $start = microtime(TRUE);
  $data = $wscall
    ->call($method, $replacements, $data, $options, $key, $tokens, $cache_tag);
  $end = microtime(TRUE);
  $this->status = $wscall
    ->lastCallStatus();
  if ($this->state
    ->get('wsdata_debug_mode')) {
    ksm($this->status);
  }

  // Track performance information.
  $duration = $end - $start;
  $this->performance['calls']++;
  $this->performance['runtime'] += $duration;
  $this->performance['log'][] = [
    'wscall' => $wscall
      ->label(),
    'method' => $method,
    'runtime' => $duration,
    'cached' => $this->status['cache']['debug'] ?? '',
  ];
  return $data;
}