Saves a Profile.
Profile $profile A Profile instance:
Boolean Write operation successful
Overrides ProfilerStorageInterface::write
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);
}