public function 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

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php, line 162

Class

Profiler
Profiler.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function collect(Request $request, Response $response, \Exception $exception = null) {
  if (false === $this->enabled) {
    return;
  }
  $profile = new Profile(uniqid());
  $profile
    ->setTime(time());
  $profile
    ->setUrl($request
    ->getUri());
  $profile
    ->setIp($request->server
    ->get('REMOTE_ADDR'));
  $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;
}