public function MongoDbProfilerStorage::write

Saves a Profile.

Parameters

Profile $profile A Profile instance:

Return value

Boolean Write operation successful

Overrides ProfilerStorageInterface::write

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/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(),
  );
  $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);
}