[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/maximebf/debugbar/src/DebugBar/Bridge/Twig/ -> TraceableTwigTemplate.php (source)

   1  <?php
   2  /*
   3   * This file is part of the DebugBar package.
   4   *
   5   * (c) 2013 Maxime Bouroumeau-Fuseau
   6   *
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  namespace DebugBar\Bridge\Twig;
  12  
  13  use Twig_Template;
  14  use Twig_TemplateInterface;
  15  
  16  /**
  17   * Wraps a Twig_Template to add profiling features
  18   * 
  19   * @deprecated
  20   */
  21  class TraceableTwigTemplate extends Twig_Template implements Twig_TemplateInterface
  22  {
  23      protected $template;
  24  
  25      /**
  26       * @param TraceableTwigEnvironment $env
  27       * @param Twig_Template $template
  28       */
  29      public function __construct(TraceableTwigEnvironment $env, Twig_Template $template)
  30      {
  31          $this->env = $env;
  32          $this->template = $template;
  33      }
  34  
  35      public function __call($name, $arguments)
  36      {
  37          return call_user_func_array(array($this->template, $name), $arguments);
  38      }
  39  
  40      public function doDisplay(array $context, array $blocks = array())
  41      {
  42          return $this->template->doDisplay($context, $blocks);
  43      }
  44  
  45      public function getTemplateName()
  46      {
  47          return $this->template->getTemplateName();
  48      }
  49  
  50      public function getEnvironment()
  51      {
  52          return $this->template->getEnvironment();
  53      }
  54  
  55      public function getParent(array $context)
  56      {
  57          return $this->template->getParent($context);
  58      }
  59  
  60      public function isTraitable()
  61      {
  62          return $this->template->isTraitable();
  63      }
  64  
  65      public function displayParentBlock($name, array $context, array $blocks = array())
  66      {
  67          $this->template->displayParentBlock($name, $context, $blocks);
  68      }
  69  
  70      public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
  71      {
  72          $this->template->displayBlock($name, $context, $blocks, $useBlocks);
  73      }
  74  
  75      public function renderParentBlock($name, array $context, array $blocks = array())
  76      {
  77          return $this->template->renderParentBlock($name, $context, $blocks);
  78      }
  79  
  80      public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
  81      {
  82          return $this->template->renderBlock($name, $context, $blocks, $useBlocks);
  83      }
  84  
  85      public function hasBlock($name)
  86      {
  87          return $this->template->hasBlock($name);
  88      }
  89  
  90      public function getBlockNames()
  91      {
  92          return $this->template->getBlockNames();
  93      }
  94  
  95      public function getBlocks()
  96      {
  97          return $this->template->getBlocks();
  98      }
  99  
 100      public function display(array $context, array $blocks = array())
 101      {
 102          $start = microtime(true);
 103          $this->template->display($context, $blocks);
 104          $end = microtime(true);
 105  
 106          if ($timeDataCollector = $this->env->getTimeDataCollector()) {
 107              $name = sprintf("twig.render(%s)", $this->template->getTemplateName());
 108              $timeDataCollector->addMeasure($name, $start, $end);
 109          }
 110  
 111          $this->env->addRenderedTemplate(array(
 112              'name' => $this->template->getTemplateName(),
 113              'render_time' => $end - $start
 114          ));
 115      }
 116  
 117      public function render(array $context)
 118      {
 119          $level = ob_get_level();
 120          ob_start();
 121          try {
 122              $this->display($context);
 123          } catch (Exception $e) {
 124              while (ob_get_level() > $level) {
 125                  ob_end_clean();
 126              }
 127  
 128              throw $e;
 129          }
 130  
 131          return ob_get_clean();
 132      }
 133  
 134      public static function clearCache()
 135      {
 136          Twig_Template::clearCache();
 137      }
 138  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer