public function Profiler::collect in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-kernel/Profiler/Profiler.php \Symfony\Component\HttpKernel\Profiler\Profiler::collect()
Collects data for the given Response.
Parameters
Request $request A Request instance:
Response $response A Response instance:
\Exception $exception An exception instance if the request threw one:
Return value
Profile|null A Profile instance or null if the profiler is disabled
File
- vendor/
symfony/ http-kernel/ Profiler/ Profiler.php, line 194
Class
- Profiler
- Profiler.
Namespace
Symfony\Component\HttpKernel\ProfilerCode
public function collect(Request $request, Response $response, \Exception $exception = null) {
if (false === $this->enabled) {
return;
}
$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
$profile
->setTime(time());
$profile
->setUrl($request
->getUri());
$profile
->setIp($request
->getClientIp());
$profile
->setMethod($request
->getMethod());
$profile
->setStatusCode($response
->getStatusCode());
$response->headers
->set('X-Debug-Token', $profile
->getToken());
foreach ($this->collectors as $collector) {
$collector
->collect($request, $response, $exception);
// we need to clone for sub-requests
$profile
->addCollector(clone $collector);
}
return $profile;
}