Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / lib / Twig / Extension / Profiler.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 class Twig_Extension_Profiler extends Twig_Extension
13 {
14     private $actives = array();
15
16     public function __construct(Twig_Profiler_Profile $profile)
17     {
18         $this->actives[] = $profile;
19     }
20
21     public function enter(Twig_Profiler_Profile $profile)
22     {
23         $this->actives[0]->addProfile($profile);
24         array_unshift($this->actives, $profile);
25     }
26
27     public function leave(Twig_Profiler_Profile $profile)
28     {
29         $profile->leave();
30         array_shift($this->actives);
31
32         if (1 === count($this->actives)) {
33             $this->actives[0]->leave();
34         }
35     }
36
37     public function getNodeVisitors()
38     {
39         return array(new Twig_Profiler_NodeVisitor_Profiler(get_class($this)));
40     }
41
42     public function getName()
43     {
44         return 'profiler';
45     }
46 }
47
48 class_alias('Twig_Extension_Profiler', 'Twig\Extension\ProfilerExtension', false);
49 class_exists('Twig_Profiler_Profile');