Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2 from AlarSuu/initiate-profiling-id
Browse files Browse the repository at this point in the history
Initiate profiling ID early
  • Loading branch information
lauripiisang authored Aug 23, 2017
2 parents 04df520 + 909ffbc commit 146700e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Xhgui/Profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Xhgui_Profiles

protected $_mapper;

/**
* @var MongoId lastProfilingId
*/
private static $lastProfilingId;

public function __construct(MongoDb $db)
{
$this->_collection = $db->results;
Expand All @@ -22,6 +27,18 @@ public function __construct(MongoDb $db)
*/
public function insert($profile)
{
$profile['_id'] = self::getLastProfilingId();
return $this->_collection->insert($profile, array('w' => 0));
}

/**
* Return profiling ID
* @return MongoId lastProfilingId
*/
public static function getLastProfilingId() {
if (!self::$lastProfilingId) {
self::$lastProfilingId = new MongoId();
}
return self::$lastProfilingId;
}
}

0 comments on commit 146700e

Please sign in to comment.