function ServicesDataCollector::collect

File

webprofiler/src/DataCollector/ServicesDataCollector.php, line 36

Class

ServicesDataCollector
Class ServicesDataCollector

Namespace

Drupal\webprofiler\DataCollector

Code

public function collect(Request $request, Response $response, \Exception $exception = NULL) {
    if ($this->getServicesCount()) {
        $tracedData = [];
        if ($this->container instanceof TraceableContainer) {
            $tracedData = $this->container
                ->getTracedData();
        }
        foreach (array_keys($this->getServices()) as $id) {
            $this->data['services'][$id]['initialized'] = $this->container
                ->initialized($id) ? TRUE : FALSE;
            $this->data['services'][$id]['time'] = isset($tracedData[$id]) ? $tracedData[$id] : NULL;
        }
    }
}