Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DumpDataCollector.php

function DumpDataCollector::collect

Overrides DataCollectorInterface::collect

File

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

Class

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

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

public function collect(Request $request, Response $response, ?\Throwable $exception = null) : void {
    if (!$this->dataCount) {
        $this->data = [];
    }
    // Sub-requests and programmatic calls stay in the collected profile.
    if ($this->dumper || $this->requestStack && $this->requestStack
        ->getMainRequest() !== $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') && !str_contains($response->headers
        ->get('Content-Type') ?? '', 'html') || 'html' !== $request->getRequestFormat() || false === strripos($response->getContent(), '</body>')) {
        if ($response->headers
            ->has('Content-Type') && str_contains($response->headers
            ->get('Content-Type') ?? '', 'html')) {
            $dumper = new HtmlDumper('php://output', $this->charset);
        }
        else {
            $dumper = new CliDumper('php://output', $this->charset);
        }
        $dumper->setDisplayOptions([
            'fileLinkFormat' => $this->fileLinkFormat,
        ]);
        foreach ($this->data as $dump) {
            $this->doDump($dumper, $dump['data'], $dump['name'], $dump['file'], $dump['line'], $dump['label'] ?? '');
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal