function ProfilerSubscriber::onKernelResponse

Handles the onKernelResponse event.

File

webprofiler/src/EventSubscriber/ProfilerSubscriber.php, line 65

Class

ProfilerSubscriber

Namespace

Drupal\webprofiler\EventSubscriber

Code

public function onKernelResponse(FilterResponseEvent $event) {
    $master = $event->isMasterRequest();
    if ($this->onlyMasterRequests && !$master) {
        return;
    }
    if ($this->onlyException && NULL === $this->exception) {
        return;
    }
    $request = $event->getRequest();
    $exception = $this->exception;
    $this->exception = NULL;
    if (NULL !== $this->matcher && !$this->matcher
        ->matches($request)) {
        return;
    }
    if (!($profile = $this->profiler
        ->collect($request, $event->getResponse(), $exception))) {
        return;
    }
    $this->profiles[$request] = $profile;
    $this->parents[$request] = $this->requestStack
        ->getParentRequest();
}