From 3bc35591a4afc70d77cab2aba601c8fdd5164c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20S=C3=A1gi-Kaz=C3=A1r?= Date: Thu, 5 May 2016 01:54:06 +0200 Subject: [PATCH 1/2] Replace plugins package with client-common Applied fixes from StyleCI Add plugins dependency back as fallback Remove auto (default) config from plugins Update changelog Make sure to use a plugin version with correct interface --- CHANGELOG.md | 2 ++ ClientFactory/PluginClientFactory.php | 4 ++-- Collector/MessageJournal.php | 2 +- DependencyInjection/HttplugExtension.php | 20 ++++++++++++++++++-- Resources/config/data-collector.xml | 2 +- Resources/config/plugins.xml | 14 +++++++------- composer.json | 3 ++- 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 284fc6e1..65f82be1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - Guzzle 6 client is now created according to the Httplug specifications with automated minimal behaviour. Make sure you configure the Httplug plugins as needed, for example if you want to get exceptions for failure HTTP status codes. +- **[BC] PluginClientFactory returns an instance of `Http\Client\Common\PluginClient`** (see [php-http/client-common#14](https://github.com/php-http/client-common/pull/14)) +- Plugins are loaded from their new packages, fall back to `php-http/plugins` if necessary ### Fixed diff --git a/ClientFactory/PluginClientFactory.php b/ClientFactory/PluginClientFactory.php index 2e0d81ff..120066e3 100644 --- a/ClientFactory/PluginClientFactory.php +++ b/ClientFactory/PluginClientFactory.php @@ -2,8 +2,8 @@ namespace Http\HttplugBundle\ClientFactory; -use Http\Client\Plugin\Plugin; -use Http\Client\Plugin\PluginClient; +use Http\Client\Common\Plugin; +use Http\Client\Common\PluginClient; /** * This factory creates a PluginClient. diff --git a/Collector/MessageJournal.php b/Collector/MessageJournal.php index dca7ccf3..8930d085 100644 --- a/Collector/MessageJournal.php +++ b/Collector/MessageJournal.php @@ -3,7 +3,7 @@ namespace Http\HttplugBundle\Collector; use Http\Client\Exception; -use Http\Client\Plugin\Journal; +use Http\Client\Common\Plugin\Journal; use Http\Message\Formatter; use Http\Message\Formatter\SimpleFormatter; use Psr\Http\Message\RequestInterface; diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php index ca41fd1f..506647d4 100644 --- a/DependencyInjection/HttplugExtension.php +++ b/DependencyInjection/HttplugExtension.php @@ -2,8 +2,11 @@ namespace Http\HttplugBundle\DependencyInjection; -use Http\Client\Plugin\AuthenticationPlugin; -use Http\Client\Plugin\PluginClient; +use Http\Client\Common\Plugin\AuthenticationPlugin; +use Http\Client\Common\Plugin\CachePlugin; +use Http\Client\Common\Plugin\LoggerPlugin; +use Http\Client\Common\Plugin\StopwatchPlugin; +use Http\Client\Common\PluginClient; use Http\HttplugBundle\ClientFactory\DummyClient; use Http\Message\Authentication\BasicAuth; use Http\Message\Authentication\Bearer; @@ -119,6 +122,7 @@ private function configurePlugins(ContainerBuilder $container, array $config) foreach ($config as $name => $pluginConfig) { $pluginId = 'httplug.plugin.'.$name; + if ($pluginConfig['enabled']) { $def = $container->getDefinition($pluginId); $this->configurePluginByName($name, $def, $pluginConfig); @@ -137,6 +141,10 @@ private function configurePluginByName($name, Definition $definition, array $con { switch ($name) { case 'cache': + // To preserve BC, we check the existence of the new plugin class and use it if available + if (class_exists(CachePlugin::class)) { + $definition->setClass(CachePlugin::class); + } $definition ->replaceArgument(0, new Reference($config['cache_pool'])) ->replaceArgument(1, new Reference($config['stream_factory'])) @@ -152,6 +160,10 @@ private function configurePluginByName($name, Definition $definition, array $con $definition->replaceArgument(0, new Reference($config['journal'])); break; case 'logger': + // To preserve BC, we check the existence of the new plugin class and use it if available + if (class_exists(LoggerPlugin::class)) { + $definition->setClass(LoggerPlugin::class); + } $definition->replaceArgument(0, new Reference($config['logger'])); if (!empty($config['formatter'])) { $definition->replaceArgument(1, new Reference($config['formatter'])); @@ -166,6 +178,10 @@ private function configurePluginByName($name, Definition $definition, array $con $definition->addArgument($config['retry']); break; case 'stopwatch': + // To preserve BC, we check the existence of the new plugin class and use it if available + if (class_exists(StopwatchPlugin::class)) { + $definition->setClass(StopwatchPlugin::class); + } $definition->replaceArgument(0, new Reference($config['stopwatch'])); break; } diff --git a/Resources/config/data-collector.xml b/Resources/config/data-collector.xml index 680e806d..6f18a30e 100644 --- a/Resources/config/data-collector.xml +++ b/Resources/config/data-collector.xml @@ -10,7 +10,7 @@ null - + diff --git a/Resources/config/plugins.xml b/Resources/config/plugins.xml index 3c7debac..864a6fe7 100644 --- a/Resources/config/plugins.xml +++ b/Resources/config/plugins.xml @@ -9,21 +9,21 @@ - - + + - - - + + + null - - + + diff --git a/composer.json b/composer.json index b7605c77..4ec3a483 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "php": ">=5.5", "php-http/client-implementation": "^1.0", "php-http/message-factory": "^1.0.2", - "php-http/plugins": "^1.0", + "php-http/client-common": "^1.1", + "php-http/plugins": "^1.1", "symfony/options-resolver": "^2.7|^3.0", "symfony/framework-bundle": "^2.7|^3.0" }, From 092d8419cfb78410d8fc072470ee196414eddd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20S=C3=A1gi-Kaz=C3=A1r?= Date: Wed, 18 May 2016 18:47:34 +0200 Subject: [PATCH 2/2] Use new packages, remove php-http/plugins --- CHANGELOG.md | 2 +- DependencyInjection/HttplugExtension.php | 15 --------------- Resources/config/plugins.xml | 6 +++--- composer.json | 4 +++- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65f82be1..51eccdcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Make sure you configure the Httplug plugins as needed, for example if you want to get exceptions for failure HTTP status codes. - **[BC] PluginClientFactory returns an instance of `Http\Client\Common\PluginClient`** (see [php-http/client-common#14](https://github.com/php-http/client-common/pull/14)) -- Plugins are loaded from their new packages, fall back to `php-http/plugins` if necessary +- Plugins are loaded from their new packages ### Fixed diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php index 506647d4..df43e3c8 100644 --- a/DependencyInjection/HttplugExtension.php +++ b/DependencyInjection/HttplugExtension.php @@ -3,9 +3,6 @@ namespace Http\HttplugBundle\DependencyInjection; use Http\Client\Common\Plugin\AuthenticationPlugin; -use Http\Client\Common\Plugin\CachePlugin; -use Http\Client\Common\Plugin\LoggerPlugin; -use Http\Client\Common\Plugin\StopwatchPlugin; use Http\Client\Common\PluginClient; use Http\HttplugBundle\ClientFactory\DummyClient; use Http\Message\Authentication\BasicAuth; @@ -141,10 +138,6 @@ private function configurePluginByName($name, Definition $definition, array $con { switch ($name) { case 'cache': - // To preserve BC, we check the existence of the new plugin class and use it if available - if (class_exists(CachePlugin::class)) { - $definition->setClass(CachePlugin::class); - } $definition ->replaceArgument(0, new Reference($config['cache_pool'])) ->replaceArgument(1, new Reference($config['stream_factory'])) @@ -160,10 +153,6 @@ private function configurePluginByName($name, Definition $definition, array $con $definition->replaceArgument(0, new Reference($config['journal'])); break; case 'logger': - // To preserve BC, we check the existence of the new plugin class and use it if available - if (class_exists(LoggerPlugin::class)) { - $definition->setClass(LoggerPlugin::class); - } $definition->replaceArgument(0, new Reference($config['logger'])); if (!empty($config['formatter'])) { $definition->replaceArgument(1, new Reference($config['formatter'])); @@ -178,10 +167,6 @@ private function configurePluginByName($name, Definition $definition, array $con $definition->addArgument($config['retry']); break; case 'stopwatch': - // To preserve BC, we check the existence of the new plugin class and use it if available - if (class_exists(StopwatchPlugin::class)) { - $definition->setClass(StopwatchPlugin::class); - } $definition->replaceArgument(0, new Reference($config['stopwatch'])); break; } diff --git a/Resources/config/plugins.xml b/Resources/config/plugins.xml index 864a6fe7..7980222a 100644 --- a/Resources/config/plugins.xml +++ b/Resources/config/plugins.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + @@ -18,13 +18,13 @@ - + null - + diff --git a/composer.json b/composer.json index 4ec3a483..b8ebe963 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,9 @@ "php-http/client-implementation": "^1.0", "php-http/message-factory": "^1.0.2", "php-http/client-common": "^1.1", - "php-http/plugins": "^1.1", + "php-http/cache-plugin": "^1.0", + "php-http/logger-plugin": "^1.0", + "php-http/stopwatch-plugin": "^1.0", "symfony/options-resolver": "^2.7|^3.0", "symfony/framework-bundle": "^2.7|^3.0" },