Collects data for the given Response.
Request $request A Request instance:
Response $response A Response instance:
\Exception $exception An exception instance if the request threw one:
Profile|null A Profile instance or null if the profiler is disabled
public function collect(Request $request, Response $response, \Exception $exception = null) {
if (false === $this->enabled) {
return;
}
$profile = new Profile(substr(sha1(uniqid(mt_rand(), true)), 0, 6));
$profile
->setTime(time());
$profile
->setUrl($request
->getUri());
$profile
->setIp($request
->getClientIp());
$profile
->setMethod($request
->getMethod());
$response->headers
->set('X-Debug-Token', $profile
->getToken());
foreach ($this->collectors as $collector) {
$collector
->collect($request, $response, $exception);
// forces collectors to become "read/only" (they loose their object dependencies)
$profile
->addCollector(unserialize(serialize($collector)));
}
return $profile;
}