vendor/pimcore/pimcore/lib/Templating/TimedPhpEngine.php line 57

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. namespace Pimcore\Templating;
  15. use Psr\Container\ContainerInterface;
  16. use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
  17. use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
  18. use Symfony\Component\Stopwatch\Stopwatch;
  19. use Symfony\Component\Templating\Loader\LoaderInterface;
  20. use Symfony\Component\Templating\TemplateNameParserInterface;
  21. /**
  22.  * Times the time spent to render a template. This is the same class as the core TimedPhpEngine, but extends our custom
  23.  * PHP engine.
  24.  */
  25. class TimedPhpEngine extends PhpEngine
  26. {
  27.     /**
  28.      * @var Stopwatch
  29.      */
  30.     protected $stopwatch;
  31.     /**
  32.      * @param TemplateNameParserInterface $parser    A TemplateNameParserInterface instance
  33.      * @param ContainerInterface          $container A ContainerInterface instance
  34.      * @param LoaderInterface             $loader    A LoaderInterface instance
  35.      * @param Stopwatch                   $stopwatch A Stopwatch instance
  36.      * @param GlobalVariables             $globals   A GlobalVariables instance
  37.      */
  38.     public function __construct(TemplateNameParserInterface $parserContainerInterface $containerLoaderInterface $loaderStopwatch $stopwatchGlobalVariables $globals null)
  39.     {
  40.         parent::__construct($parser$container$loader$globals);
  41.         $this->stopwatch $stopwatch;
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     public function render($name, array $parameters = [])
  47.     {
  48.         $e $this->stopwatch->start(sprintf('template.php (%s)'$name), 'template');
  49.         /** @var TemplateReference $name */
  50.         $ret parent::render($name$parameters);
  51.         $e->stop();
  52.         return $ret;
  53.     }
  54. }