diff --git a/integrations/symfony-bundle.rst b/integrations/symfony-bundle.rst index c531ddb..4d161e0 100644 --- a/integrations/symfony-bundle.rst +++ b/integrations/symfony-bundle.rst @@ -403,6 +403,49 @@ client: plugins: - 'acme_plugin' +If you want to configure your plugin using the bundle configuration, you can +create a class that implements ``PluginConfigurator`` and define ``configurator`` plugins. + + +.. code-block:: php + + final class CustomPluginConfigurator implements PluginConfigurator + { + public static function getConfigTreeBuilder() : TreeBuilder + { + $treeBuilder = new TreeBuilder('custom_plugin'); + $rootNode = $treeBuilder->getRootNode(); + + $rootNode + ->children() + ->scalarNode('name') + ->isRequired() + ->cannotBeEmpty() + ->end() + ->end(); + + return $treeBuilder; + } + + public function create(array $config) : CustomPlugin + { + return new CustomPlugin($config['name']); + } + } + +.. code-block:: yaml + + // config.yml + httplug: + clients: + acme: + factory: 'httplug.factory.guzzle6' + plugins: + - configurator: + id: 'App\CustomPluginConfigurator' + config: + name: 'foo' + Authentication -------------- diff --git a/integrations/symfony-full-configuration.rst b/integrations/symfony-full-configuration.rst index 95a6a91..ffc63fb 100644 --- a/integrations/symfony-full-configuration.rst +++ b/integrations/symfony-full-configuration.rst @@ -113,6 +113,12 @@ This page shows an example of all configuration values provided by the bundle. plugins: # Can reference a globally configured plugin service - 'httplug.plugin.authentication.my_wsse' + # Configure a plugin using a custom PluginConfigurator + - configurator: + id: App\Httplug\Plugin\MyPluginConfigurator + config: + foo: 'bar' + baz: 'qux' # Can configure a plugin customized for this client - cache: cache_pool: 'my_other_pool'