Skip to content

Commit ade2a1a

Browse files
leomotybarryvdh
authored andcommitted
Deprecate TwigCollector and friends (php-debugbar#425)
* Update twig demo to use TwigProfileCollector * Update documentation on twig bridge collector * Deprecate TwigCollector TraceableTwigEnvironment and TraceableTwigTemplate
1 parent 6c4277f commit ade2a1a

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

demo/bridge/twig/index.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
$debugbarRenderer->setBaseUrl('../../../src/DebugBar/Resources');
77

88
$loader = new Twig_Loader_Filesystem('.');
9-
$twig = new DebugBar\Bridge\Twig\TraceableTwigEnvironment(new Twig_Environment($loader), $debugbar['time']);
9+
$twig = new Twig_Environment($loader);
10+
$profile = new Twig_Profiler_Profile();
11+
$twig->addExtension(new DebugBar\Bridge\Twig\TimeableTwigExtensionProfiler($profile, $debugbar['time']));
1012

11-
$debugbar->addCollector(new DebugBar\Bridge\Twig\TwigCollector($twig));
13+
$debugbar->addCollector(new DebugBar\Bridge\TwigProfileCollector($profile));
1214

1315
render_demo_page(function() use ($twig) {
1416
echo $twig->render('hello.html', array('name' => 'peter pan'));

docs/bridge_collectors.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,9 @@ Display log messages and sent mail using `DebugBar\Bridge\SwiftMailer\SwiftLogCo
9090

9191
http://twig.sensiolabs.org/
9292

93-
Collects info about rendered templates using `DebugBar\Bridge\Twig\TwigCollector`.
94-
You need to wrap your `Twig_Environment` object into a `DebugBar\Bridge\Twig\TraceableTwigEnvironment` object.
95-
96-
$loader = new Twig_Loader_Filesystem('.');
97-
$env = new DebugBar\Bridge\Twig\TraceableTwigEnvironment(new Twig_Environment($loader));
98-
$debugbar->addCollector(new DebugBar\Bridge\Twig\TwigCollector($env));
99-
100-
You can provide a `DebugBar\DataCollector\TimeDataCollector` as the second argument of
101-
`TraceableTwigEnvironment` so render operation can be measured.
102-
103-
## Twig (Profiler)
104-
105-
An alternative to `DebugBar\Bridge\Twig\TwigCollector` for newer versions of twig.
10693
This collector uses the class `Twig_Extension_Profiler` to collect info about rendered
10794
templates, blocks and macros.
108-
You need to inject the root-`Twig_Profiler_Profile` into the collector:
95+
You need to inject the root `Twig_Profiler_Profile` into the collector:
10996

11097
$loader = new Twig_Loader_Filesystem('.');
11198
$env = new Twig_Environment($loader);
@@ -119,6 +106,6 @@ You can optionally use `DebugBar\Bridge\Twig\TimeableTwigExtensionProfiler` in p
119106
$loader = new Twig_Loader_Filesystem('.');
120107
$env = new Twig_Environment($loader);
121108
$profile = new Twig_Profiler_Profile();
122-
$env->addExtension(new TimeableTwigExtensionProfiler($profile, $debugbar['time']));
109+
$env->addExtension(new DebugBar\Bridge\Twig\TimeableTwigExtensionProfiler($profile, $debugbar['time']));
123110
$debugbar->addCollector(new DebugBar\Bridge\TwigProfileCollector($profile));
124111

src/DebugBar/Bridge/Twig/TraceableTwigEnvironment.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
/**
2626
* Wrapped a Twig Environment to provide profiling features
27+
*
28+
* @deprecated
2729
*/
2830
class TraceableTwigEnvironment extends Twig_Environment
2931
{

src/DebugBar/Bridge/Twig/TraceableTwigTemplate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* Wraps a Twig_Template to add profiling features
18+
*
19+
* @deprecated
1820
*/
1921
class TraceableTwigTemplate extends Twig_Template implements Twig_TemplateInterface
2022
{

src/DebugBar/Bridge/Twig/TwigCollector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* $env = new TraceableTwigEnvironment(new Twig_Environment($loader));
2727
* $debugbar->addCollector(new TwigCollector($env));
2828
* </code>
29+
*
30+
* @deprecated use DebugBar\Bridge\TwigProfileCollector instead
2931
*/
3032
class TwigCollector extends DataCollector implements Renderable, AssetProvider
3133
{

0 commit comments

Comments
 (0)