You are here

public function DumpDataCollector::collect in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php \Symfony\Component\HttpKernel\DataCollector\DumpDataCollector::collect()

Collects data for the given Request and Response.

Parameters

Request $request A Request instance:

Response $response A Response instance:

\Exception $exception An Exception instance:

Overrides DataCollectorInterface::collect

File

vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php, line 140

Class

DumpDataCollector
@author Nicolas Grekas <p@tchwork.com>

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

public function collect(Request $request, Response $response, \Exception $exception = null) {

  // Sub-requests and programmatic calls stay in the collected profile.
  if ($this->dumper || $this->requestStack && $this->requestStack
    ->getMasterRequest() !== $request || $request
    ->isXmlHttpRequest() || $request->headers
    ->has('Origin')) {
    return;
  }

  // In all other conditions that remove the web debug toolbar, dumps are written on the output.
  if (!$this->requestStack || !$response->headers
    ->has('X-Debug-Token') || $response
    ->isRedirection() || $response->headers
    ->has('Content-Type') && false === strpos($response->headers
    ->get('Content-Type'), 'html') || 'html' !== $request
    ->getRequestFormat() || false === strripos($response
    ->getContent(), '</body>')) {
    if ($response->headers
      ->has('Content-Type') && false !== strpos($response->headers
      ->get('Content-Type'), 'html')) {
      $this->dumper = new HtmlDumper('php://output', $this->charset);
    }
    else {
      $this->dumper = new CliDumper('php://output', $this->charset);
    }
    foreach ($this->data as $dump) {
      $this
        ->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']);
    }
  }
}