Skip to content

Commit 3a0f534

Browse files
iainmckayNyholm
authored andcommitted
Adds an option to disable the data collector (#73)
* Adds an option to disable the data collector * Fixing style violation
1 parent 8d06a3b commit 3a0f534

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/DependencyInjection/CacheExtension.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public function load(array $configs, ContainerBuilder $container)
5757
$this->registerServices($container, $config);
5858

5959
// Add toolbar and data collector if we are debuging
60-
if ($container->getParameter('kernel.debug')) {
60+
if (!isset($config['data_collector']['enabled'])) {
61+
$config['data_collector']['enabled'] = $container->getParameter('kernel.debug');
62+
}
63+
64+
if ($config['data_collector']['enabled']) {
6165
$loader->load('data-collector.yml');
6266
}
6367

src/DependencyInjection/Configuration.php

+17
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function getConfigTreeBuilder()
4040
->append($this->addSerializerSection())
4141
->append($this->addValidationSection())
4242
->append($this->addLoggingSection())
43+
->append($this->addDataCollectorSection())
4344
->end();
4445

4546
return $treeBuilder;
@@ -236,4 +237,20 @@ private function addRouterSection()
236237

237238
return $node;
238239
}
240+
241+
/**
242+
* @return ArrayNodeDefinition
243+
*/
244+
private function addDataCollectorSection()
245+
{
246+
$tree = new TreeBuilder();
247+
$node = $tree->root('data_collector');
248+
249+
$node
250+
->children()
251+
->booleanNode('enabled')->end()
252+
->end();
253+
254+
return $node;
255+
}
239256
}

0 commit comments

Comments
 (0)