You are here

public function WSDataService::destruct in Web Service Data 2.0.x

Performs destruct operations.

Overrides DestructableInterface::destruct

File

src/WSDataService.php, line 56

Class

WSDataService
Service for processing WSData requests.

Namespace

Drupal\wsdata

Code

public function destruct() {
  if ($this->performance['calls'] > 0 and $this->state
    ->get('wsdata_performance_log', 0)) {
    $message = $this
      ->t('WSData Performance - %calls calls in %runtime seconds.', [
      '%calls' => $this->performance['calls'],
      '%runtime' => round($this->performance['runtime'], 3),
    ]);
    $message .= "<br>\nCall list:\n<ol>\n";
    foreach ($this->performance['log'] as $log) {
      $method = '';
      if (isset($method)) {
        $method = ':' . $log['method'];
      }
      $message .= '<li>' . $log['wscall'] . $method . ' - ' . round($log['runtime'], 3) . "s (" . $log['cached'] . ")</li>\n";
    }
    $message .= '</ol>';
    $this->logger
      ->get('wsdata')
      ->debug($message);
  }
}