public function TimeDataCollector::getDrupalSettings in Devel 8
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/TimeDataCollector.php \Drupal\webprofiler\DataCollector\TimeDataCollector::getDrupalSettings()
- 8.2 webprofiler/src/DataCollector/TimeDataCollector.php \Drupal\webprofiler\DataCollector\TimeDataCollector::getDrupalSettings()
- 4.x webprofiler/src/DataCollector/TimeDataCollector.php \Drupal\webprofiler\DataCollector\TimeDataCollector::getDrupalSettings()
Return value
array
Overrides DrupalDataCollectorInterface::getDrupalSettings
File
- webprofiler/
src/ DataCollector/ TimeDataCollector.php, line 107
Class
- TimeDataCollector
- Class TimeDataCollector.
Namespace
Drupal\webprofiler\DataCollectorCode
public function getDrupalSettings() {
/** @var StopwatchEvent[] $collectedEvents */
$collectedEvents = $this
->getEvents();
if (!empty($collectedEvents)) {
$sectionPeriods = $collectedEvents['__section__']
->getPeriods();
$endTime = end($sectionPeriods)
->getEndTime();
$events = [];
foreach ($collectedEvents as $key => $collectedEvent) {
if ('__section__' != $key) {
$periods = [];
foreach ($collectedEvent
->getPeriods() as $period) {
$periods[] = [
'start' => sprintf("%F", $period
->getStartTime()),
'end' => sprintf("%F", $period
->getEndTime()),
];
}
$events[] = [
"name" => $key,
"category" => $collectedEvent
->getCategory(),
"origin" => sprintf("%F", $collectedEvent
->getOrigin()),
"starttime" => sprintf("%F", $collectedEvent
->getStartTime()),
"endtime" => sprintf("%F", $collectedEvent
->getEndTime()),
"duration" => sprintf("%F", $collectedEvent
->getDuration()),
"memory" => sprintf("%.1F", $collectedEvent
->getMemory() / 1024 / 1024),
"periods" => $periods,
];
}
}
return [
'time' => [
'events' => $events,
'endtime' => $endTime,
],
];
}
else {
return [
'time' => [
'events' => [],
'endtime' => 0,
],
];
}
}