public function display(array $context, array $blocks = array())
 {
     $startTime = microtime(true);
     $templateListBefore = TemplateDebugInfo::getTemplatesList();
     parent::display($context, $blocks);
     $endTime = microtime(true);
     $templateListAfter = TemplateDebugInfo::getTemplatesList();
     TemplateDebugInfo::addTemplate($this->getTemplateName(), $this->computeExecutionTime(round(($endTime - $startTime) * 1000), $templateListBefore['full'], $templateListAfter['full']));
 }
Exemplo n.º 2
0
 public function display(array $context, array $blocks = array())
 {
     $startTime = microtime(true);
     $templateListBefore = TemplateDebugInfo::getTemplatesList();
     // Bufferize to be able to insert template name as HTML comments if applicable.
     // Layout template name will only appear at the end, to avoid potential quirks with old browsers
     // when comments appear before doctype declaration.
     ob_start();
     parent::display($context, $blocks);
     $templateResult = ob_get_clean();
     $templateName = $this->getTemplateName();
     // Check if template name ends with "html.twig", indicating this is an HTML template.
     $isHtmlTemplate = substr($templateName, -strlen('html.twig')) === 'html.twig';
     // Display start template comment, if applicable.
     if ($isHtmlTemplate) {
         if (stripos(trim($templateResult), '<!doctype') !== false) {
             $templateResult = preg_replace('#(<!doctype[^>]+>)#im', "\$1\n<!-- START " . $templateName . ' -->', $templateResult);
         } else {
             echo "\n<!-- START {$templateName} -->\n";
         }
     }
     // Display stop template comment after result, if applicable.
     if ($isHtmlTemplate) {
         $bodyPos = stripos($templateResult, '</body>');
         if ($bodyPos !== false) {
             // Add layout template name before </body>, to avoid display quirks in some browsers.
             echo substr($templateResult, 0, $bodyPos) . "\n<!-- STOP {$templateName} -->\n" . substr($templateResult, $bodyPos);
         } else {
             echo $templateResult;
             echo "\n<!-- STOP {$templateName} -->\n";
         }
     } else {
         echo $templateResult;
     }
     $endTime = microtime(true);
     $templateListAfter = TemplateDebugInfo::getTemplatesList();
     TemplateDebugInfo::addTemplate($this->getTemplateName(), $this->computeExecutionTime(round(($endTime - $startTime) * 1000), $templateListBefore['full'], $templateListAfter['full']));
 }
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $this->data = ['templates' => TemplateDebugInfo::getTemplatesList()];
 }
 /**
  * Collects data for the given Request and Response.
  *
  * @param Request    $request   A Request instance
  * @param Response   $response  A Response instance
  * @param \Exception $exception An Exception instance
  *
  * @api
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $this->data = array('count' => $this->logger->getCount(), 'calls_logging_enabled' => $this->logger->isCallsLoggingEnabled(), 'calls' => $this->logger->getCalls(), 'handlers' => $this->logger->getLoadedUnCachedHandlers(), 'templates' => TemplateDebugInfo::getTemplatesList(), 'legacy_templates' => TemplateDebugInfo::getLegacyTemplatesList($this->legacyKernel));
 }