function Profiler::collect
Collects data for the given Response.
File
-
vendor/
symfony/ http-kernel/ Profiler/ Profiler.php, line 130
Class
- Profiler
- Profiler.
Namespace
Symfony\Component\HttpKernel\ProfilerCode
public function collect(Request $request, Response $response, ?\Throwable $exception = null) : ?Profile {
if (false === $this->enabled) {
return null;
}
$profile = new Profile(bin2hex(random_bytes(3)));
$profile->setTime(time());
$profile->setUrl($request->getUri());
$profile->setMethod($request->getMethod());
$profile->setStatusCode($response->getStatusCode());
try {
$profile->setIp($request->getClientIp());
} catch (ConflictingHeadersException) {
$profile->setIp('Unknown');
}
if ($request->attributes
->has('_virtual_type')) {
$profile->setVirtualType($request->attributes
->get('_virtual_type'));
}
if ($prevToken = $response->headers
->get('X-Debug-Token')) {
$response->headers
->set('X-Previous-Debug-Token', $prevToken);
}
$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;
}