File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
tests/Unit/DependencyInjection Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ class_exists(AbstractArgument::class) ? new AbstractArgument(sprintf('Added in %
125
125
$ container ->setAlias ('console.command.stimulus_component_debug ' , 'ux.twig_component.command.debug ' )
126
126
->setDeprecated ('symfony/ux-twig-component ' , '2.13 ' , '%alias_id% ' );
127
127
128
- if ($ container ->getParameter ('kernel.debug ' )) {
128
+ if ($ container ->getParameter ('kernel.debug ' ) && $ config [ ' profiler ' ] ) {
129
129
$ loader ->load ('debug.php ' );
130
130
}
131
131
}
@@ -182,6 +182,10 @@ public function getConfigTreeBuilder(): TreeBuilder
182
182
->scalarNode ('anonymous_template_directory ' )
183
183
->info ('Defaults to `components` ' )
184
184
->end ()
185
+ ->booleanNode ('profiler ' )
186
+ ->info ('Enables the profiler for Twig Component (in debug mode) ' )
187
+ ->defaultValue ('%kernel.debug% ' )
188
+ ->end ()
185
189
->end ();
186
190
187
191
return $ treeBuilder ;
Original file line number Diff line number Diff line change @@ -36,6 +36,21 @@ public function testDataCollectorWithDebugMode()
36
36
$ this ->assertTrue ($ container ->hasDefinition ('ux.twig_component.data_collector ' ));
37
37
}
38
38
39
+ public function testDataCollectorWithDebugModeCanBeDisabled ()
40
+ {
41
+ $ container = $ this ->createContainer ();
42
+ $ container ->setParameter ('kernel.debug ' , true );
43
+ $ container ->registerExtension (new TwigComponentExtension ());
44
+ $ container ->loadFromExtension ('twig_component ' , [
45
+ 'defaults ' => [],
46
+ 'anonymous_template_directory ' => 'components/ ' ,
47
+ 'profiler ' => false ,
48
+ ]);
49
+ $ this ->compileContainer ($ container );
50
+
51
+ $ this ->assertFalse ($ container ->hasDefinition ('ux.twig_component.data_collector ' ));
52
+ }
53
+
39
54
public function testDataCollectorWithoutDebugMode ()
40
55
{
41
56
$ container = $ this ->createContainer ();
@@ -44,6 +59,7 @@ public function testDataCollectorWithoutDebugMode()
44
59
$ container ->loadFromExtension ('twig_component ' , [
45
60
'defaults ' => [],
46
61
'anonymous_template_directory ' => 'components/ ' ,
62
+ 'profiler ' => true ,
47
63
]);
48
64
$ this ->compileContainer ($ container );
49
65
You can’t perform that action at this time.
0 commit comments