[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
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 DebugBar\DataCollector\AssetProvider; 14 use DebugBar\DataCollector\DataCollector; 15 use DebugBar\DataCollector\Renderable; 16 17 /** 18 * Collects data about rendered templates 19 * 20 * http://twig.sensiolabs.org/ 21 * 22 * Your Twig_Environment object needs to be wrapped in a 23 * TraceableTwigEnvironment object 24 * 25 * <code> 26 * $env = new TraceableTwigEnvironment(new Twig_Environment($loader)); 27 * $debugbar->addCollector(new TwigCollector($env)); 28 * </code> 29 * 30 * @deprecated use DebugBar\Bridge\TwigProfileCollector instead 31 */ 32 class TwigCollector extends DataCollector implements Renderable, AssetProvider 33 { 34 public function __construct(TraceableTwigEnvironment $twig) 35 { 36 $this->twig = $twig; 37 } 38 39 public function collect() 40 { 41 $templates = array(); 42 $accuRenderTime = 0; 43 44 foreach ($this->twig->getRenderedTemplates() as $tpl) { 45 $accuRenderTime += $tpl['render_time']; 46 $templates[] = array( 47 'name' => $tpl['name'], 48 'render_time' => $tpl['render_time'], 49 'render_time_str' => $this->formatDuration($tpl['render_time']) 50 ); 51 } 52 53 return array( 54 'nb_templates' => count($templates), 55 'templates' => $templates, 56 'accumulated_render_time' => $accuRenderTime, 57 'accumulated_render_time_str' => $this->formatDuration($accuRenderTime) 58 ); 59 } 60 61 public function getName() 62 { 63 return 'twig'; 64 } 65 66 public function getWidgets() 67 { 68 return array( 69 'twig' => array( 70 'icon' => 'leaf', 71 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', 72 'map' => 'twig', 73 'default' => json_encode(array('templates' => array())), 74 ), 75 'twig:badge' => array( 76 'map' => 'twig.nb_templates', 77 'default' => 0 78 ) 79 ); 80 } 81 82 public function getAssets() 83 { 84 return array( 85 'css' => 'widgets/templates/widget.css', 86 'js' => 'widgets/templates/widget.js' 87 ); 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |