function WebprofilerEventSubscriber::onKernelResponse

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event:

File

webprofiler/src/EventSubscriber/WebprofilerEventSubscriber.php, line 47

Class

WebprofilerEventSubscriber
Class WebprofilerEventSubscriber

Namespace

Drupal\webprofiler\EventSubscriber

Code

public function onKernelResponse(FilterResponseEvent $event) {
    $response = $event->getResponse();
    $request = $event->getRequest();
    if ($response->headers
        ->has('X-Debug-Token') && NULL !== $this->urlGenerator) {
        $response->headers
            ->set('X-Debug-Token-Link', $this->urlGenerator
            ->generate('webprofiler.dashboard', [
            'profile' => $response->headers
                ->get('X-Debug-Token'),
        ]));
    }
    // do not capture redirects or modify XML HTTP Requests
    if ($request->isXmlHttpRequest()) {
        return;
    }
    if ($this->currentUser
        ->hasPermission('view webprofiler toolbar')) {
        $this->injectToolbar($response);
    }
}