Skip to content

Commit ba3eee7

Browse files
Nyholmdbu
authored andcommitted
Added stopwatch plugin (#102)
Added stopwatch plugin
1 parent d42d86c commit ba3eee7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
### Added
77

88
- Support for BatchClient
9+
- The stopwatch plugin in included by default when using profiling.
910

1011
### Changed
1112

DependencyInjection/HttplugExtension.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ private function configureClient(ContainerBuilder $container, $name, array $argu
218218
$pluginClientOptions = [];
219219

220220
if ($profiling) {
221+
if (!in_array('httplug.plugin.stopwatch', $arguments['plugins'])) {
222+
// Add the stopwatch plugin
223+
array_unshift($arguments['plugins'], 'httplug.plugin.stopwatch');
224+
}
225+
221226
// Tell the plugin journal what plugins we used
222227
$container
223228
->getDefinition('httplug.collector.plugin_journal')
@@ -340,6 +345,12 @@ private function registerAutoDiscoverableClient(ContainerBuilder $container, $na
340345
$pluginClientOptions = [];
341346

342347
if ($profiling) {
348+
// Tell the plugin journal what plugins we used
349+
$container
350+
->getDefinition('httplug.collector.plugin_journal')
351+
->addMethodCall('setPlugins', [$name, ['httplug.plugin.stopwatch']])
352+
;
353+
343354
$debugPluginServiceId = $this->registerDebugPlugin($container, $serviceId);
344355

345356
$pluginClientOptions['debug_plugins'] = [new Reference($debugPluginServiceId)];
@@ -348,7 +359,7 @@ private function registerAutoDiscoverableClient(ContainerBuilder $container, $na
348359
$container
349360
->register($serviceId, DummyClient::class)
350361
->setFactory([PluginClientFactory::class, 'createPluginClient'])
351-
->setArguments([[], $factory, [], $pluginClientOptions])
362+
->setArguments([[new Reference('httplug.plugin.stopwatch')], $factory, [], $pluginClientOptions])
352363
;
353364

354365
return $serviceId;

0 commit comments

Comments
 (0)