You are here

public function MongoDbProfilerStorage::write in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage::write()

Saves a Profile.

Parameters

Profile $profile A Profile instance:

Return value

bool Write operation successful

Overrides ProfilerStorageInterface::write

File

vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php, line 74

Class

MongoDbProfilerStorage

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function write(Profile $profile) {
  $this
    ->cleanup();
  $record = array(
    '_id' => $profile
      ->getToken(),
    'parent' => $profile
      ->getParentToken(),
    'data' => base64_encode(serialize($profile
      ->getCollectors())),
    'ip' => $profile
      ->getIp(),
    'method' => $profile
      ->getMethod(),
    'url' => $profile
      ->getUrl(),
    'time' => $profile
      ->getTime(),
    'status_code' => $profile
      ->getStatusCode(),
  );
  $result = $this
    ->getMongo()
    ->update(array(
    '_id' => $profile
      ->getToken(),
  ), array_filter($record, function ($v) {
    return !empty($v);
  }), array(
    'upsert' => true,
  ));
  return (bool) (isset($result['ok']) ? $result['ok'] : $result);
}