Skip to content

Commit d4cf0bd

Browse files
committed
Rename toolbar config to profiling
1 parent d42d86c commit d4cf0bd

File tree

8 files changed

+44
-20
lines changed

8 files changed

+44
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
### Deprecated
1616

1717
- `auto` value in `toolbar.enabled` config
18+
- `toolbar` config, use `profiling` instead
1819

1920

2021
## 1.2.2 - 2016-07-19

DependencyInjection/Configuration.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ public function getConfigTreeBuilder()
6969
return $v;
7070
})
7171
->end()
72+
->beforeNormalization() // @deprecated toolbar in 1.3.0, use profiling instead
73+
->ifTrue(function ($v) {
74+
return is_array($v) && array_key_exists('toolbar', $v) && is_array($v['toolbar']);
75+
})
76+
->then(function ($v) {
77+
if (array_key_exists('enabled', $v['toolbar']) && 'auto' === $v['toolbar']['enabled']) {
78+
$v['toolbar']['enabled'] = $this->debug; // @deprecated value auto in 1.3.0
79+
}
80+
81+
if (array_key_exists('profiling', $v) && is_array($v['profiling'])) {
82+
$v['profiling'] = array_merge($v['profiling'], $v['toolbar']);
83+
} else {
84+
$v['profiling'] = $v['toolbar'];
85+
}
86+
87+
unset($v['toolbar']);
88+
89+
return $v;
90+
})
91+
->end()
7292
->children()
7393
->arrayNode('main_alias')
7494
->addDefaultsIfNotSet()
@@ -90,17 +110,14 @@ public function getConfigTreeBuilder()
90110
->scalarNode('stream_factory')->defaultNull()->end()
91111
->end()
92112
->end()
93-
->arrayNode('toolbar')
113+
->arrayNode('profiling')
94114
->addDefaultsIfNotSet()
115+
->treatFalseLike(['enabled' => false])
116+
->treatTrueLike(['enabled' => true])
117+
->treatNullLike(['enabled' => $this->debug])
95118
->info('Extend the debug profiler with information about requests.')
96119
->children()
97-
->booleanNode('enabled') // @deprecated value auto in 1.3.0
98-
->beforeNormalization()
99-
->ifString()
100-
->then(function ($v) {
101-
return 'auto' === $v ? $this->debug : $v;
102-
})
103-
->end()
120+
->booleanNode('enabled')
104121
->info('Turn the toolbar on or off. Defaults to kernel debug mode.')
105122
->defaultValue($this->debug)
106123
->end()

DependencyInjection/HttplugExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ public function load(array $configs, ContainerBuilder $container)
5353
}
5454

5555
// Configure toolbar
56-
if ($config['toolbar']['enabled']) {
56+
if ($config['profiling']['enabled']) {
5757
$loader->load('data-collector.xml');
5858

59-
if (!empty($config['toolbar']['formatter'])) {
59+
if (!empty($config['profiling']['formatter'])) {
6060
// Add custom formatter
6161
$container
6262
->getDefinition('httplug.collector.debug_collector')
63-
->replaceArgument(0, new Reference($config['toolbar']['formatter']))
63+
->replaceArgument(0, new Reference($config['profiling']['formatter']))
6464
;
6565
}
6666

6767
$container
6868
->getDefinition('httplug.formatter.full_http_message')
69-
->addArgument($config['toolbar']['captured_body_length'])
69+
->addArgument($config['profiling']['captured_body_length'])
7070
;
7171
}
7272

@@ -91,7 +91,7 @@ private function configureClients(ContainerBuilder $container, array $config)
9191
$first = $name;
9292
}
9393

94-
$this->configureClient($container, $name, $arguments, $config['toolbar']['enabled']);
94+
$this->configureClient($container, $name, $arguments, $config['profiling']['enabled']);
9595
}
9696

9797
// If we have clients configured
@@ -294,7 +294,7 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
294294
$container,
295295
'auto_discovered_client',
296296
[HttpClientDiscovery::class, 'find'],
297-
$config['toolbar']['enabled']
297+
$config['profiling']['enabled']
298298
);
299299
}
300300

@@ -309,7 +309,7 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
309309
$container,
310310
'auto_discovered_async',
311311
[HttpAsyncClientDiscovery::class, 'find'],
312-
$config['toolbar']['enabled']
312+
$config['profiling']['enabled']
313313
);
314314
}
315315

Tests/Resources/Fixtures/config/full.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'uri_factory' => 'Http\Message\UriFactory\GuzzleUriFactory',
1414
'stream_factory' => 'Http\Message\StreamFactory\GuzzleStreamFactory',
1515
],
16-
'toolbar' => [
16+
'profiling' => [
1717
'enabled' => true,
1818
'formatter' => 'my_toolbar_formatter',
1919
'captured_body_length' => 0,

Tests/Resources/Fixtures/config/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<uri-factory>Http\Message\UriFactory\GuzzleUriFactory</uri-factory>
1515
<stream-factory>Http\Message\StreamFactory\GuzzleStreamFactory</stream-factory>
1616
</classes>
17-
<toolbar enabled="true" formatter="my_toolbar_formatter" captured_body_length="0"/>
17+
<profiling enabled="true" formatter="my_toolbar_formatter" captured_body_length="0"/>
1818
<plugins>
1919
<authentication>
2020
<my_basic type="basic" username="foo" password="bar"/>

Tests/Resources/Fixtures/config/full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ httplug:
99
message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
1010
uri_factory: Http\Message\UriFactory\GuzzleUriFactory
1111
stream_factory: Http\Message\StreamFactory\GuzzleStreamFactory
12-
toolbar:
12+
profiling:
1313
enabled: true
1414
formatter: my_toolbar_formatter
1515
captured_body_length: 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
httplug:
2+
toolbar:
3+
enabled: true
4+
formatter: null
5+
captured_body_length: 0

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testEmptyConfiguration()
3939
'stream_factory' => null,
4040
],
4141
'clients' => [],
42-
'toolbar' => [
42+
'profiling' => [
4343
'enabled' => true,
4444
'formatter' => null,
4545
'captured_body_length' => 0,
@@ -95,6 +95,7 @@ public function testEmptyConfiguration()
9595
'config/empty.yml',
9696
'config/empty.xml',
9797
'config/empty.php',
98+
'config/toolbar.yml',
9899
'config/toolbar_auto.yml',
99100
]);
100101

@@ -119,7 +120,7 @@ public function testSupportsAllConfigFormats()
119120
'stream_factory' => 'Http\Message\StreamFactory\GuzzleStreamFactory',
120121
],
121122
'clients' => [],
122-
'toolbar' => [
123+
'profiling' => [
123124
'enabled' => true,
124125
'formatter' => 'my_toolbar_formatter',
125126
'captured_body_length' => 0,

0 commit comments

Comments
 (0)