From 8f84f285460d4ddce0fe1cd08837adaa993e5999 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Fri, 18 Aug 2017 20:03:06 +0200 Subject: [PATCH 01/13] add PluginClientFactory support --- Collector/PluginClientFactory.php | 69 ++++++++++++++++ Collector/PluginClientFactorySubscriber.php | 45 +++++++++++ DependencyInjection/HttplugExtension.php | 79 ++++--------------- Resources/config/data-collector.xml | 12 +++ Resources/config/services.xml | 3 + Tests/Functional/ServiceInstantiationTest.php | 22 ++++++ .../HttplugExtensionTest.php | 24 +++--- composer.json | 2 +- 8 files changed, 176 insertions(+), 80 deletions(-) create mode 100644 Collector/PluginClientFactory.php create mode 100644 Collector/PluginClientFactorySubscriber.php diff --git a/Collector/PluginClientFactory.php b/Collector/PluginClientFactory.php new file mode 100644 index 00000000..6db7625f --- /dev/null +++ b/Collector/PluginClientFactory.php @@ -0,0 +1,69 @@ +collector = $collector; + $this->formatter = $formatter; + $this->stopwatch = $stopwatch; + } + + /** + * @param HttpClient|HttpAsyncClient $client + * @param Plugin[] $plugins + * @param array $options { + * + * @var string $client_name to give client a name which may be used when displaying client information like in + * the HTTPlugBundle profiler. + * } + * + * @see PluginClient constructor for PluginClient specific $options. + * + * @return PluginClient + */ + public function createClient($client, array $plugins = [], array $options = []) + { + $plugins = array_map(function (Plugin $plugin) { + return new ProfilePlugin($plugin, $this->collector, $this->formatter); + }, $plugins); + + $clientName = isset($options['client_name']) ? $options['client_name'] : 'Default'; + array_unshift($plugins, new StackPlugin($this->collector, $this->formatter, $clientName)); + unset($options['client_name']); + + if (!$client instanceof ProfileClient) { + $client = new ProfileClient($client, $this->collector, $this->formatter, $this->stopwatch); + } + + return new PluginClient($client, $plugins, $options); + } +} diff --git a/Collector/PluginClientFactorySubscriber.php b/Collector/PluginClientFactorySubscriber.php new file mode 100644 index 00000000..51270fcd --- /dev/null +++ b/Collector/PluginClientFactorySubscriber.php @@ -0,0 +1,45 @@ +factory = $factory; + } + + /** + * Make sure to profile clients created using PluginClientFactory. + * + * @param Event $e + */ + public function onEvent(Event $e) + { + PluginClientFactory::setFactory([$this->factory, 'createClient']); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ + 'kernel.request' => ['onEvent', 1024], + 'console.command' => ['onEvent', 1024], + ]; + } +} diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php index 6f5df8f1..3ab2d3f5 100644 --- a/DependencyInjection/HttplugExtension.php +++ b/DependencyInjection/HttplugExtension.php @@ -7,8 +7,8 @@ use Http\Client\Common\HttpMethodsClient; use Http\Client\Common\Plugin\AuthenticationPlugin; use Http\Client\Common\PluginClient; -use Http\HttplugBundle\ClientFactory\PluginClientFactory; -use Http\HttplugBundle\Collector\ProfilePlugin; +use Http\Client\Common\PluginClientFactory; +use Http\Client\HttpClient; use Http\Message\Authentication\BasicAuth; use Http\Message\Authentication\Bearer; use Http\Message\Authentication\Wsse; @@ -72,7 +72,7 @@ public function load(array $configs, ContainerBuilder $container) ; } - $this->configureClients($container, $config, $profilingEnabled); + $this->configureClients($container, $config); $this->configurePlugins($container, $config['plugins']); // must be after clients, as clients.X.plugins might use plugins as templates that will be removed $this->configureAutoDiscoveryClients($container, $config); } @@ -82,9 +82,8 @@ public function load(array $configs, ContainerBuilder $container) * * @param ContainerBuilder $container * @param array $config - * @param bool $profiling */ - private function configureClients(ContainerBuilder $container, array $config, $profiling) + private function configureClients(ContainerBuilder $container, array $config) { $first = null; $clients = []; @@ -95,7 +94,7 @@ private function configureClients(ContainerBuilder $container, array $config, $p $first = $name; } - $this->configureClient($container, $name, $arguments, $this->isConfigEnabled($container, $config['profiling'])); + $this->configureClient($container, $name, $arguments); $clients[] = $name; } @@ -266,9 +265,8 @@ private function configureAuthentication(ContainerBuilder $container, array $con * @param ContainerBuilder $container * @param string $clientName * @param array $arguments - * @param bool $profiling */ - private function configureClient(ContainerBuilder $container, $clientName, array $arguments, $profiling) + private function configureClient(ContainerBuilder $container, $clientName, array $arguments) { $serviceId = 'httplug.client.'.$clientName; @@ -285,23 +283,17 @@ private function configureClient(ContainerBuilder $container, $clientName, array } } - $pluginClientOptions = []; - if ($profiling) { - //Decorate each plugin with a ProfilePlugin instance. - $plugins = array_map(function ($pluginServiceId) use ($container) { - $this->decoratePluginWithProfilePlugin($container, $pluginServiceId); - - return $pluginServiceId.'.debug'; - }, $plugins); - - // To profile the requests, add a StackPlugin as first plugin in the chain. - $stackPluginId = $this->configureStackPlugin($container, $clientName, $serviceId); - array_unshift($plugins, $stackPluginId); - } + $container + ->register($serviceId.'.client', HttpClient::class) + ->setFactory([new Reference($arguments['factory']), 'createClient']) + ->addArgument($arguments['config']) + ->setPublic(false) + ; $container ->register($serviceId, PluginClient::class) - ->setFactory([PluginClientFactory::class, 'createPluginClient']) + ->setFactory([new Reference(PluginClientFactory::class), 'createClient']) + ->addArgument(new Reference($serviceId.'.client')) ->addArgument( array_map( function ($id) { @@ -310,9 +302,6 @@ function ($id) { $plugins ) ) - ->addArgument(new Reference($arguments['factory'])) - ->addArgument($arguments['config']) - ->addArgument($pluginClientOptions) ; /* @@ -432,44 +421,4 @@ private function configurePlugin(ContainerBuilder $container, $serviceId, $plugi return $pluginServiceId; } - - /** - * Decorate the plugin service with a ProfilePlugin service. - * - * @param ContainerBuilder $container - * @param string $pluginServiceId - */ - private function decoratePluginWithProfilePlugin(ContainerBuilder $container, $pluginServiceId) - { - $container->register($pluginServiceId.'.debug', ProfilePlugin::class) - ->setArguments([ - new Reference($pluginServiceId), - new Reference('httplug.collector.collector'), - new Reference('httplug.collector.formatter'), - ]) - ->setPublic(false); - } - - /** - * Configure a StackPlugin for a client. - * - * @param ContainerBuilder $container - * @param string $clientName Client name to display in the profiler. - * @param string $serviceId Client service id. Used as base for the StackPlugin service id. - * - * @return string configured StackPlugin service id - */ - private function configureStackPlugin(ContainerBuilder $container, $clientName, $serviceId) - { - $pluginServiceId = $serviceId.'.plugin.stack'; - - $definition = class_exists(ChildDefinition::class) - ? new ChildDefinition('httplug.plugin.stack') - : new DefinitionDecorator('httplug.plugin.stack'); - - $definition->addArgument($clientName); - $container->setDefinition($pluginServiceId, $definition); - - return $pluginServiceId; - } } diff --git a/Resources/config/data-collector.xml b/Resources/config/data-collector.xml index 890e11c1..0a25dc9d 100644 --- a/Resources/config/data-collector.xml +++ b/Resources/config/data-collector.xml @@ -84,5 +84,17 @@ + + + + + + + + + + + + diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 1f82018a..23688423 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -44,6 +44,9 @@ + + + diff --git a/Tests/Functional/ServiceInstantiationTest.php b/Tests/Functional/ServiceInstantiationTest.php index e305ac0a..e7520425 100644 --- a/Tests/Functional/ServiceInstantiationTest.php +++ b/Tests/Functional/ServiceInstantiationTest.php @@ -11,6 +11,11 @@ use Http\HttplugBundle\Collector\StackPlugin; use Nyholm\NSA; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Profiler\Profiler; class ServiceInstantiationTest extends WebTestCase @@ -71,4 +76,21 @@ public function testProfilingDecoration() $this->assertInstanceOf(ProfilePlugin::class, $plugins[3]); $this->assertInstanceOf(ProfilePlugin::class, $plugins[4]); } + + /** + * {@inheritdoc} + */ + protected static function bootKernel(array $options = []) + { + $kernel = parent::bootKernel($options); + + /** @var EventDispatcherInterface $dispatcher */ + $dispatcher = $kernel->getContainer()->get('event_dispatcher'); + + $event = new GetResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST); + + $dispatcher->dispatch(KernelEvents::REQUEST, $event); + + return $kernel; + } } diff --git a/Tests/Unit/DependencyInjection/HttplugExtensionTest.php b/Tests/Unit/DependencyInjection/HttplugExtensionTest.php index af4dc686..b3a6b352 100644 --- a/Tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/Tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -116,15 +116,14 @@ public function testClientPlugins() ]); $plugins = [ - 'httplug.client.acme.plugin.stack', - 'httplug.client.acme.plugin.decoder.debug', - 'httplug.plugin.redirect.debug', - 'httplug.client.acme.plugin.add_host.debug', - 'httplug.client.acme.plugin.header_append.debug', - 'httplug.client.acme.plugin.header_defaults.debug', - 'httplug.client.acme.plugin.header_set.debug', - 'httplug.client.acme.plugin.header_remove.debug', - 'httplug.client.acme.authentication.my_basic.debug', + 'httplug.client.acme.plugin.decoder', + 'httplug.plugin.redirect', + 'httplug.client.acme.plugin.add_host', + 'httplug.client.acme.plugin.header_append', + 'httplug.client.acme.plugin.header_defaults', + 'httplug.client.acme.plugin.header_set', + 'httplug.client.acme.plugin.header_remove', + 'httplug.client.acme.authentication.my_basic', ]; $pluginReferences = array_map(function ($id) { return new Reference($id); @@ -134,7 +133,7 @@ public function testClientPlugins() foreach ($plugins as $id) { $this->assertContainerBuilderHasService($id); } - $this->assertContainerBuilderHasServiceDefinitionWithArgument('httplug.client.acme', 0, $pluginReferences); + $this->assertContainerBuilderHasServiceDefinitionWithArgument('httplug.client.acme', 1, $pluginReferences); } /** @@ -196,10 +195,7 @@ public function testProfilingWhenToolbarIsSpecificallyOn() ] ); - $def = $this->container->findDefinition('httplug.client'); - $arguments = $def->getArguments(); - - $this->assertTrue(isset($arguments[3])); + $this->assertContainerBuilderHasService('httplug.collector.plugin_client_factory_subscriber'); } public function testOverrideProfillingFormatter() diff --git a/composer.json b/composer.json index 173f421e..df876413 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "^5.5 || ^7.0", "php-http/client-implementation": "^1.0", "php-http/message-factory": "^1.0.2", - "php-http/client-common": "^1.2", + "php-http/client-common": "^1.6", "php-http/cache-plugin": "^1.4", "php-http/logger-plugin": "^1.0", "php-http/stopwatch-plugin": "^1.0", From 2ab6ef41be02a613a3afbbd0f0b9a40c1dfdaa8a Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Wed, 23 Aug 2017 10:24:34 +0200 Subject: [PATCH 02/13] deprecate ClientFactory\PluginClientFactory --- CHANGELOG.md | 6 ++++++ ClientFactory/PluginClientFactory.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb12f2bf..9bcb0963 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +## Unreleased + +### Deprecated + +- The `Http\HttplugBundle\ClientFactory\PluginClientFactory` class. + ## 1.7.1 - 2017-08-04 ### Fixed diff --git a/ClientFactory/PluginClientFactory.php b/ClientFactory/PluginClientFactory.php index 9213f878..39ba69f8 100644 --- a/ClientFactory/PluginClientFactory.php +++ b/ClientFactory/PluginClientFactory.php @@ -2,6 +2,8 @@ namespace Http\HttplugBundle\ClientFactory; +@trigger_error('The '.__NAMESPACE__.'\PluginClientFactory class is deprecated since version 1.8 and will be removed in 2.0.', E_USER_DEPRECATED); + use Http\Client\Common\Plugin; use Http\Client\Common\PluginClient; From 70119d1f2366273b0043928a3eaf256f62439b9e Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Wed, 23 Aug 2017 10:31:39 +0200 Subject: [PATCH 03/13] add PluginClientFactory and PluginClientFactorySubscriber class comments --- Collector/PluginClientFactory.php | 8 ++++++++ Collector/PluginClientFactorySubscriber.php | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/Collector/PluginClientFactory.php b/Collector/PluginClientFactory.php index 6db7625f..ac02ee6d 100644 --- a/Collector/PluginClientFactory.php +++ b/Collector/PluginClientFactory.php @@ -8,6 +8,14 @@ use Http\Client\HttpClient; use Symfony\Component\Stopwatch\Stopwatch; +/** + * This factory is used as a replacement for Http\Client\Common\PluginClientFactory when profiling is enabled. It create + * PluginClient instances with all profiling decorators and extra plugins. + * + * @author Fabien Bourigault + * + * @internal + */ final class PluginClientFactory { /** diff --git a/Collector/PluginClientFactorySubscriber.php b/Collector/PluginClientFactorySubscriber.php index 51270fcd..fcbcded5 100644 --- a/Collector/PluginClientFactorySubscriber.php +++ b/Collector/PluginClientFactorySubscriber.php @@ -7,6 +7,15 @@ use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * This subscriber ensure that every PluginClient created when using Http\Client\Common\PluginClientFactory without + * using the Symfony dependency injection container use the Http\HttplugBundle\Collector\PluginClientFactory factory + * when profiling is enabled. This allows 0 config profiling of third party libraries which use HTTPlug. + * + * @author Fabien Bourigault + * + * @internal + */ final class PluginClientFactorySubscriber implements EventSubscriberInterface { /** From 749d889bed9872f97eb945672b268b3b16d3ba69 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Wed, 23 Aug 2017 23:37:39 +0200 Subject: [PATCH 04/13] improve ClientFactory\PluginClientFactory deprecation --- ClientFactory/PluginClientFactory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ClientFactory/PluginClientFactory.php b/ClientFactory/PluginClientFactory.php index 39ba69f8..10092758 100644 --- a/ClientFactory/PluginClientFactory.php +++ b/ClientFactory/PluginClientFactory.php @@ -2,7 +2,7 @@ namespace Http\HttplugBundle\ClientFactory; -@trigger_error('The '.__NAMESPACE__.'\PluginClientFactory class is deprecated since version 1.8 and will be removed in 2.0.', E_USER_DEPRECATED); +@trigger_error('The '.__NAMESPACE__.'\PluginClientFactory class is deprecated since version 1.8 and will be removed in 2.0. Use Http\Client\Common\PluginClientFactory instead.', E_USER_DEPRECATED); use Http\Client\Common\Plugin; use Http\Client\Common\PluginClient; @@ -10,6 +10,8 @@ /** * This factory creates a PluginClient. * + * @deprecated + * * @author Tobias Nyholm */ final class PluginClientFactory From 5bec5d691bed672241975944a299f6e27979102d Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Wed, 23 Aug 2017 23:38:02 +0200 Subject: [PATCH 05/13] fix typos --- Collector/PluginClientFactory.php | 4 ++-- Collector/PluginClientFactorySubscriber.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Collector/PluginClientFactory.php b/Collector/PluginClientFactory.php index ac02ee6d..d98b0051 100644 --- a/Collector/PluginClientFactory.php +++ b/Collector/PluginClientFactory.php @@ -9,8 +9,8 @@ use Symfony\Component\Stopwatch\Stopwatch; /** - * This factory is used as a replacement for Http\Client\Common\PluginClientFactory when profiling is enabled. It create - * PluginClient instances with all profiling decorators and extra plugins. + * This factory is used as a replacement for Http\Client\Common\PluginClientFactory when profiling is enabled. It + * creates PluginClient instances with all profiling decorators and extra plugins. * * @author Fabien Bourigault * diff --git a/Collector/PluginClientFactorySubscriber.php b/Collector/PluginClientFactorySubscriber.php index fcbcded5..068be8c6 100644 --- a/Collector/PluginClientFactorySubscriber.php +++ b/Collector/PluginClientFactorySubscriber.php @@ -8,8 +8,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * This subscriber ensure that every PluginClient created when using Http\Client\Common\PluginClientFactory without - * using the Symfony dependency injection container use the Http\HttplugBundle\Collector\PluginClientFactory factory + * This subscriber ensures that every PluginClient created when using Http\Client\Common\PluginClientFactory without + * using the Symfony dependency injection container uses the Http\HttplugBundle\Collector\PluginClientFactory factory * when profiling is enabled. This allows 0 config profiling of third party libraries which use HTTPlug. * * @author Fabien Bourigault From 08d0321d6157b16fd4192a9c227b4c9365dca279 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 28 Aug 2017 13:16:16 +0200 Subject: [PATCH 06/13] use client_name option for configured clients --- DependencyInjection/HttplugExtension.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php index 3ab2d3f5..4d59f3be 100644 --- a/DependencyInjection/HttplugExtension.php +++ b/DependencyInjection/HttplugExtension.php @@ -302,6 +302,9 @@ function ($id) { $plugins ) ) + ->addArgument([ + 'client_name' => $clientName, + ]) ; /* From 2782c1eed2b9227181e21ec2aee3ff2a43cc86f3 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 28 Aug 2017 13:51:48 +0200 Subject: [PATCH 07/13] update composer.json --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index df876413..7b48f143 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,8 @@ "conflict": { "php-http/guzzle6-adapter": "<1.1" }, + "minimum-stability": "dev", + "prefer-dist": true, "autoload": { "psr-4": { "Http\\HttplugBundle\\": "" @@ -71,7 +73,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } From 3b58eb50f089d2069506d2a490e6c4769e1cde7e Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 28 Aug 2017 14:01:17 +0200 Subject: [PATCH 08/13] fix composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7b48f143..04cb9dd9 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "php-http/guzzle6-adapter": "<1.1" }, "minimum-stability": "dev", - "prefer-dist": true, + "prefer-stable": true, "autoload": { "psr-4": { "Http\\HttplugBundle\\": "" From 35ca27791e82462396df583984a3eabdda5b9acf Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 28 Aug 2017 14:11:09 +0200 Subject: [PATCH 09/13] remove prefer-stable when testing against dev dependencies --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5238a8b7..8c24c0cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ matrix: before_install: - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; + - if [ "$DEPENDENCIES" = "dev" ]; then sed -i '/prefer-stable/d' composer.json; fi; - if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; - if [ $COVERAGE != true ]; then phpenv config-rm xdebug.ini; fi; From 729a884b36a79f2e3a54d8bd07d37785e54627e6 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Wed, 30 Aug 2017 14:32:07 +0200 Subject: [PATCH 10/13] add compatibility with old KernelTestCase::bootKernel signature --- Tests/Functional/ServiceInstantiationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Functional/ServiceInstantiationTest.php b/Tests/Functional/ServiceInstantiationTest.php index e7520425..817d8aa4 100644 --- a/Tests/Functional/ServiceInstantiationTest.php +++ b/Tests/Functional/ServiceInstantiationTest.php @@ -82,15 +82,15 @@ public function testProfilingDecoration() */ protected static function bootKernel(array $options = []) { - $kernel = parent::bootKernel($options); + parent::bootKernel($options); /** @var EventDispatcherInterface $dispatcher */ - $dispatcher = $kernel->getContainer()->get('event_dispatcher'); + $dispatcher = static::$kernel->getContainer()->get('event_dispatcher'); - $event = new GetResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST); + $event = new GetResponseEvent(static::$kernel, new Request(), HttpKernelInterface::MASTER_REQUEST); $dispatcher->dispatch(KernelEvents::REQUEST, $event); - return $kernel; + return static::$kernel; } } From 47a48ee7fa8a702344fd6321fa7fee0b69c2a8e0 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 4 Sep 2017 09:45:35 +0200 Subject: [PATCH 11/13] require symfony/dependency injection ^2.8.3 || ^3.0.3 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 04cb9dd9..ad0fe1be 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "php-http/message": "^1.4", "php-http/discovery": "^1.0", "twig/twig": "^1.18 || ^2.0", - "symfony/asset": "^2.8 || ^3.0" + "symfony/asset": "^2.8 || ^3.0", + "symfony/dependency-injection": "^2.8.3 || ^3.0.3" }, "require-dev": { "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.1", From 65b04ac6cf30ba77d35d64c630f57dc5e08b6f3d Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 4 Sep 2017 10:05:01 +0200 Subject: [PATCH 12/13] update the changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bcb0963..83bb9219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee ## Unreleased +### Added + +- Any third party library using `Http\Client\Common\PluginClientFactory` to create `Http\Client\Common\PluginClient` +instances now gets zero config profiling. +- `Http\Client\Common\PluginClientFactory` factory service. + +### Changed + +- `ProfilePlugin` and `StackPlugin` are no longer registered as (private) services decorators. Those decorators are now +created through the `Http\HttplugBundle\Collector\PluginClientFactory`. + ### Deprecated - The `Http\HttplugBundle\ClientFactory\PluginClientFactory` class. From cef534d7d24fc1cac1b4c8d93f570c38c1c61e12 Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Mon, 4 Sep 2017 21:58:56 +0200 Subject: [PATCH 13/13] rename PluginClientFactorySubscriber to PluginClientFactoryListener --- ...ntFactorySubscriber.php => PluginClientFactoryListener.php} | 2 +- Resources/config/data-collector.xml | 2 +- Tests/Unit/DependencyInjection/HttplugExtensionTest.php | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) rename Collector/{PluginClientFactorySubscriber.php => PluginClientFactoryListener.php} (94%) diff --git a/Collector/PluginClientFactorySubscriber.php b/Collector/PluginClientFactoryListener.php similarity index 94% rename from Collector/PluginClientFactorySubscriber.php rename to Collector/PluginClientFactoryListener.php index 068be8c6..6dbf3056 100644 --- a/Collector/PluginClientFactorySubscriber.php +++ b/Collector/PluginClientFactoryListener.php @@ -16,7 +16,7 @@ * * @internal */ -final class PluginClientFactorySubscriber implements EventSubscriberInterface +final class PluginClientFactoryListener implements EventSubscriberInterface { /** * @var CollectorPluginClientFactory diff --git a/Resources/config/data-collector.xml b/Resources/config/data-collector.xml index 0a25dc9d..dd3f3b85 100644 --- a/Resources/config/data-collector.xml +++ b/Resources/config/data-collector.xml @@ -91,7 +91,7 @@ - + diff --git a/Tests/Unit/DependencyInjection/HttplugExtensionTest.php b/Tests/Unit/DependencyInjection/HttplugExtensionTest.php index b3a6b352..21b7c8f1 100644 --- a/Tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/Tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -3,6 +3,7 @@ namespace Http\HttplugBundle\Tests\Unit\DependencyInjection; use Http\Client\Common\PluginClient; +use Http\HttplugBundle\Collector\PluginClientFactoryListener; use Http\HttplugBundle\DependencyInjection\HttplugExtension; use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; use Symfony\Component\DependencyInjection\Reference; @@ -195,7 +196,7 @@ public function testProfilingWhenToolbarIsSpecificallyOn() ] ); - $this->assertContainerBuilderHasService('httplug.collector.plugin_client_factory_subscriber'); + $this->assertContainerBuilderHasService(PluginClientFactoryListener::class); } public function testOverrideProfillingFormatter()