1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-05-04 13:57:55 +02:00

Fix twig demo (#602)

This commit is contained in:
erikn69 2024-02-19 15:37:40 -05:00 committed by GitHub
parent cbab4a8f45
commit 9321913520
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 10 deletions

View File

@ -5,12 +5,12 @@ include __DIR__ . '/../../bootstrap.php';
$debugbarRenderer->setBaseUrl('../../../src/DebugBar/Resources');
$loader = new Twig_Loader_Filesystem('.');
$twig = new Twig_Environment($loader);
$profile = new Twig_Profiler_Profile();
$loader = new Twig\Loader\FilesystemLoader('.');
$twig = new Twig\Environment($loader);
$profile = new Twig\Profiler\Profile();
$twig->addExtension(new DebugBar\Bridge\Twig\TimeableTwigExtensionProfiler($profile, $debugbar['time']));
$debugbar->addCollector(new DebugBar\Bridge\TwigProfileCollector($profile));
$debugbar->addCollector(new DebugBar\Bridge\NamespacedTwigProfileCollector($profile, $twig));
render_demo_page(function() use ($twig) {
echo $twig->render('hello.html', array('name' => 'peter pan'));

View File

@ -11,16 +11,17 @@
namespace DebugBar\Bridge\Twig;
use DebugBar\DataCollector\TimeDataCollector;
use Twig_Profiler_Profile;
use Twig\Extension\ProfilerExtension;
use Twig\Profiler\Profile;
/**
* Class TimeableTwigExtensionProfiler
*
* Extends Twig_Extension_Profiler to add rendering times to the TimeDataCollector
* Extends ProfilerExtension to add rendering times to the TimeDataCollector
*
* @package DebugBar\Bridge\Twig
*/
class TimeableTwigExtensionProfiler extends \Twig_Extension_Profiler
class TimeableTwigExtensionProfiler extends ProfilerExtension
{
/**
* @var \DebugBar\DataCollector\TimeDataCollector
@ -35,14 +36,14 @@ class TimeableTwigExtensionProfiler extends \Twig_Extension_Profiler
$this->timeDataCollector = $timeDataCollector;
}
public function __construct(\Twig_Profiler_Profile $profile, TimeDataCollector $timeDataCollector = null)
public function __construct(Profile $profile, TimeDataCollector $timeDataCollector = null)
{
parent::__construct($profile);
$this->timeDataCollector = $timeDataCollector;
}
public function enter(Twig_Profiler_Profile $profile)
public function enter(Profile $profile)
{
if ($this->timeDataCollector && $profile->isTemplate()) {
$this->timeDataCollector->startMeasure($profile->getName(), 'template ' . $profile->getName());
@ -50,7 +51,7 @@ class TimeableTwigExtensionProfiler extends \Twig_Extension_Profiler
parent::enter($profile);
}
public function leave(Twig_Profiler_Profile $profile)
public function leave(Profile $profile)
{
parent::leave($profile);
if ($this->timeDataCollector && $profile->isTemplate()) {