[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/twig/twig/src/Extension/ -> ProfilerExtension.php (source)

   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  namespace Twig\Extension;
  13  
  14  use Twig\Profiler\NodeVisitor\ProfilerNodeVisitor;
  15  use Twig\Profiler\Profile;
  16  
  17  class ProfilerExtension extends AbstractExtension
  18  {
  19      private $actives = [];
  20  
  21      public function __construct(Profile $profile)
  22      {
  23          $this->actives[] = $profile;
  24      }
  25  
  26      public function enter(Profile $profile)
  27      {
  28          $this->actives[0]->addProfile($profile);
  29          array_unshift($this->actives, $profile);
  30      }
  31  
  32      public function leave(Profile $profile)
  33      {
  34          $profile->leave();
  35          array_shift($this->actives);
  36  
  37          if (1 === \count($this->actives)) {
  38              $this->actives[0]->leave();
  39          }
  40      }
  41  
  42      public function getNodeVisitors()
  43      {
  44          return [new ProfilerNodeVisitor(\get_class($this))];
  45      }
  46  
  47      public function getName()
  48      {
  49          return 'profiler';
  50      }
  51  }
  52  
  53  class_alias('Twig\Extension\ProfilerExtension', 'Twig_Extension_Profiler');


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1