public function enter(\Twig_Profiler_Profile $profile) { if ($this->stopwatch && $profile->isTemplate()) { $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template'); } parent::enter($profile); }
private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false) { if ($profile->isRoot()) { $this->root = $profile->getDuration(); $start = $profile->getName(); } else { if ($profile->isTemplate()) { $start = $this->formatTemplate($profile, $prefix); } else { $start = $this->formatNonTemplate($profile, $prefix); } $prefix .= $sibling ? 'ā ' : ' '; } $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0; if ($profile->getDuration() * 1000 < 1) { $str = $start . "\n"; } else { $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent)); } $nCount = count($profile->getProfiles()); foreach ($profile as $i => $p) { $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount); } return $str; }
public function testConstructor() { $profile = new Twig_Profiler_Profile('template', 'type', 'name'); $this->assertEquals('template', $profile->getTemplate()); $this->assertEquals('type', $profile->getType()); $this->assertEquals('name', $profile->getName()); }
public function enter(\Twig_Profiler_Profile $profile) { if ($this->stopwatch && $profile->isTemplate()) { $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template'); } $this->actives[0]->addProfile($profile); array_unshift($this->actives, $profile); }
private function format(\Twig_Profiler_Profile $profile) { $tmp = array(); $tmp["template"] = $profile->getTemplate(); $tmp["name"] = $profile->getName(); $tmp["duration"] = $profile->getDuration(); $tmp["type"] = $profile->getType(); return $tmp; }
protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) { return sprintf('%sā %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName()); }
protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) { return sprintf('%sā %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName()); }
/** * Enter $profile. * * @param \Twig_Profiler_Profile $profile Profile. * * @return void */ public function enter(\Twig_Profiler_Profile $profile) { $name = 'Twig Template: ' . substr($profile->getName(), strlen(ROOT) + 1); DebugTimer::start($name, __d('twig_view', $name)); parent::enter($profile); }