|
@@ -35,6 +35,7 @@ class Profiler
|
|
|
protected $url;
|
|
|
protected $time;
|
|
|
protected $empty;
|
|
|
+ protected $children;
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -142,7 +143,7 @@ class Profiler
|
|
|
$this->token = $token;
|
|
|
|
|
|
if (false !== $items = $this->storage->read($token)) {
|
|
|
- list($data, $this->ip, $this->url, $this->time) = $items;
|
|
|
+ list($data, $this->parent, $this->ip, $this->url, $this->time) = $items;
|
|
|
$this->set(unserialize(base64_decode($data)));
|
|
|
|
|
|
$this->empty = false;
|
|
@@ -151,6 +152,30 @@ class Profiler
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sets the parent token
|
|
|
+ *
|
|
|
+ * @param string $parent The parent token
|
|
|
+ */
|
|
|
+ public function setParent($parent)
|
|
|
+ {
|
|
|
+ $this->parent = $parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns an instance of the parent token
|
|
|
+ *
|
|
|
+ * @return Profiler
|
|
|
+ */
|
|
|
+ public function getParentToken()
|
|
|
+ {
|
|
|
+ if (null !== $this->parent) {
|
|
|
+ return $this->loadFromToken($this->parent);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Gets the token.
|
|
|
*
|
|
@@ -229,6 +254,23 @@ class Profiler
|
|
|
return $this->storage->find($ip, $url, $limit);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Finds children profilers.
|
|
|
+ *
|
|
|
+ * @return array An array of Profiler
|
|
|
+ */
|
|
|
+ public function getChildren()
|
|
|
+ {
|
|
|
+ if (null === $this->children) {
|
|
|
+ $this->children = array();
|
|
|
+ foreach ($this->storage->findChildren($this->token) as $token) {
|
|
|
+ $this->children[] = $this->loadFromToken($token['token']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->children;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Collects data for the given Response.
|
|
|
*
|
|
@@ -248,7 +290,6 @@ class Profiler
|
|
|
$collector->collect($request, $response, $exception);
|
|
|
}
|
|
|
|
|
|
- $this->parent = '';
|
|
|
$this->ip = $request->server->get('REMOTE_ADDR');
|
|
|
$this->url = $request->getUri();
|
|
|
$this->time = time();
|