[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

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

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   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 Symfony\Bridge\Twig\Extension;
  13  
  14  use Symfony\Component\Stopwatch\Stopwatch;
  15  use Twig\Extension\ProfilerExtension as BaseProfilerExtension;
  16  use Twig\Profiler\Profile;
  17  
  18  /**
  19   * @author Fabien Potencier <fabien@symfony.com>
  20   */
  21  class ProfilerExtension extends BaseProfilerExtension
  22  {
  23      private $stopwatch;
  24      private $events;
  25  
  26      public function __construct(Profile $profile, Stopwatch $stopwatch = null)
  27      {
  28          parent::__construct($profile);
  29  
  30          $this->stopwatch = $stopwatch;
  31          $this->events = new \SplObjectStorage();
  32      }
  33  
  34      public function enter(Profile $profile)
  35      {
  36          if ($this->stopwatch && $profile->isTemplate()) {
  37              $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template');
  38          }
  39  
  40          parent::enter($profile);
  41      }
  42  
  43      public function leave(Profile $profile)
  44      {
  45          parent::leave($profile);
  46  
  47          if ($this->stopwatch && $profile->isTemplate()) {
  48              $this->events[$profile]->stop();
  49              unset($this->events[$profile]);
  50          }
  51      }
  52  
  53      /**
  54       * {@inheritdoc}
  55       */
  56      public function getName()
  57      {
  58          return 'native_profiler';
  59      }
  60  }


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