function ThemeDataCollector::computeData

Parameters

\Twig_Profiler_Profile $profile:

Return value

array

1 call to ThemeDataCollector::computeData()
ThemeDataCollector::getComputedData in webprofiler/src/DataCollector/ThemeDataCollector.php

File

webprofiler/src/DataCollector/ThemeDataCollector.php, line 220

Class

ThemeDataCollector
Class ThemeDataCollector

Namespace

Drupal\webprofiler\DataCollector

Code

private function computeData(\Twig_Profiler_Profile $profile) {
    $data = [
        'template_count' => 0,
        'block_count' => 0,
        'macro_count' => 0,
    ];
    $templates = [];
    foreach ($profile as $p) {
        $d = $this->computeData($p);
        $data['template_count'] += ($p->isTemplate() ? 1 : 0) + $d['template_count'];
        $data['block_count'] += ($p->isBlock() ? 1 : 0) + $d['block_count'];
        $data['macro_count'] += ($p->isMacro() ? 1 : 0) + $d['macro_count'];
        if ($p->isTemplate()) {
            if (!isset($templates[$p->getTemplate()])) {
                $templates[$p->getTemplate()] = 1;
            }
            else {
                $templates[$p->getTemplate()]++;
            }
        }
        foreach ($d['templates'] as $template => $count) {
            if (!isset($templates[$template])) {
                $templates[$template] = $count;
            }
            else {
                $templates[$template] += $count;
            }
        }
    }
    $data['templates'] = $templates;
    return $data;
}