You are here

public function FileStorage::saveRun in XHProf 8

Saves run data.

Parameters

array $data: The data.

string $namespace: The run namespace.

string $run_id: The run ID.

Return value

string The run ID.

Overrides StorageInterface::saveRun

File

src/XHProfLib/Storage/FileStorage.php, line 84

Class

FileStorage
Provides file storage backend for xhprof runs.

Namespace

Drupal\xhprof\XHProfLib\Storage

Code

public function saveRun($data, $namespace, $run_id) {

  // Use PHP serialize function to store the XHProf's
  // raw profiler data.
  $data = serialize($data);
  $file_name = $this
    ->fileName($run_id, $namespace);
  $file = fopen($file_name, 'w');
  if ($file) {
    fwrite($file, $data);
    fclose($file);
  }
  else {
    throw new \Exception("Could not open {$file_name}\n");
  }
  return $run_id;
}