4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Extension_Profiler extends Twig_Extension
14 private $actives = array();
16 public function __construct(Twig_Profiler_Profile $profile)
18 $this->actives[] = $profile;
21 public function enter(Twig_Profiler_Profile $profile)
23 $this->actives[0]->addProfile($profile);
24 array_unshift($this->actives, $profile);
27 public function leave(Twig_Profiler_Profile $profile)
30 array_shift($this->actives);
32 if (1 === count($this->actives)) {
33 $this->actives[0]->leave();
37 public function getNodeVisitors()
39 return array(new Twig_Profiler_NodeVisitor_Profiler(get_class($this)));
42 public function getName()
48 class_alias('Twig_Extension_Profiler', 'Twig\Extension\ProfilerExtension', false);
49 class_exists('Twig_Profiler_Profile');