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:
parent
cbab4a8f45
commit
9321913520
@ -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'));
|
||||
|
@ -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()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user