Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

vendor/symfony/twig-bridge/Extension/ProfilerExtension.php line 31

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bridge\Twig\Extension;
  11. use Symfony\Component\Stopwatch\Stopwatch;
  12. use Symfony\Component\Stopwatch\StopwatchEvent;
  13. use Twig\Extension\ProfilerExtension as BaseProfilerExtension;
  14. use Twig\Profiler\Profile;
  15. /**
  16.  * @author Fabien Potencier <fabien@symfony.com>
  17.  */
  18. final class ProfilerExtension extends BaseProfilerExtension
  19. {
  20.     private $stopwatch;
  21.     /**
  22.      * @var \SplObjectStorage<Profile, StopwatchEvent>
  23.      */
  24.     private $events;
  25.     public function __construct(Profile $profileStopwatch $stopwatch null)
  26.     {
  27.         parent::__construct($profile);
  28.         $this->stopwatch $stopwatch;
  29.         $this->events = new \SplObjectStorage();
  30.     }
  31.     public function enter(Profile $profile): void
  32.     {
  33.         if ($this->stopwatch && $profile->isTemplate()) {
  34.             $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template');
  35.         }
  36.         parent::enter($profile);
  37.     }
  38.     public function leave(Profile $profile): void
  39.     {
  40.         parent::leave($profile);
  41.         if ($this->stopwatch && $profile->isTemplate()) {
  42.             $this->events[$profile]->stop();
  43.             unset($this->events[$profile]);
  44.         }
  45.     }
  46. }