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 %
125125 $ container ->setAlias ('console.command.stimulus_component_debug ' , 'ux.twig_component.command.debug ' )
126126 ->setDeprecated ('symfony/ux-twig-component ' , '2.13 ' , '%alias_id% ' );
127127
128- if ($ container ->getParameter ('kernel.debug ' )) {
128+ if ($ container ->getParameter ('kernel.debug ' ) && $ config [ ' profiler ' ] ) {
129129 $ loader ->load ('debug.php ' );
130130 }
131131 }
@@ -182,6 +182,10 @@ public function getConfigTreeBuilder(): TreeBuilder
182182 ->scalarNode ('anonymous_template_directory ' )
183183 ->info ('Defaults to `components` ' )
184184 ->end ()
185+ ->booleanNode ('profiler ' )
186+ ->info ('Enables the profiler for Twig Component (in debug mode) ' )
187+ ->defaultValue ('%kernel.debug% ' )
188+ ->end ()
185189 ->end ();
186190
187191 return $ treeBuilder ;
Original file line number Diff line number Diff line change @@ -36,6 +36,21 @@ public function testDataCollectorWithDebugMode()
3636 $ this ->assertTrue ($ container ->hasDefinition ('ux.twig_component.data_collector ' ));
3737 }
3838
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+
3954 public function testDataCollectorWithoutDebugMode ()
4055 {
4156 $ container = $ this ->createContainer ();
@@ -44,6 +59,7 @@ public function testDataCollectorWithoutDebugMode()
4459 $ container ->loadFromExtension ('twig_component ' , [
4560 'defaults ' => [],
4661 'anonymous_template_directory ' => 'components/ ' ,
62+ 'profiler ' => true ,
4763 ]);
4864 $ this ->compileContainer ($ container );
4965
You can’t perform that action at this time.
0 commit comments