File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,49 @@ client:
403403 plugins :
404404 - ' acme_plugin'
405405
406+ If you want to configure your plugin using the bundle configuration, you can
407+ create a class that implements ``PluginConfigurator `` and define ``configurator `` plugins.
408+
409+
410+ .. code-block :: php
411+
412+ final class CustomPluginConfigurator implements PluginConfigurator
413+ {
414+ public static function getConfigTreeBuilder() : TreeBuilder
415+ {
416+ $treeBuilder = new TreeBuilder('custom_plugin');
417+ $rootNode = $treeBuilder->getRootNode();
418+
419+ $rootNode
420+ ->children()
421+ ->scalarNode('name')
422+ ->isRequired()
423+ ->cannotBeEmpty()
424+ ->end()
425+ ->end();
426+
427+ return $treeBuilder;
428+ }
429+
430+ public function create(array $config) : CustomPlugin
431+ {
432+ return new CustomPlugin($config['name']);
433+ }
434+ }
435+
436+ .. code-block :: yaml
437+
438+ // config.yml
439+ httplug :
440+ clients :
441+ acme :
442+ factory : ' httplug.factory.guzzle6'
443+ plugins :
444+ - configurator :
445+ id : ' App\CustomPluginConfigurator'
446+ config :
447+ name : ' foo'
448+
406449 Authentication
407450--------------
408451
Original file line number Diff line number Diff line change @@ -113,6 +113,12 @@ This page shows an example of all configuration values provided by the bundle.
113113 plugins :
114114 # Can reference a globally configured plugin service
115115 - ' httplug.plugin.authentication.my_wsse'
116+ # Configure a plugin using a custom PluginConfigurator
117+ - configurator :
118+ id : App\Httplug\Plugin\MyPluginConfigurator
119+ config :
120+ foo : ' bar'
121+ baz : ' qux'
116122 # Can configure a plugin customized for this client
117123 - cache :
118124 cache_pool : ' my_other_pool'
You can’t perform that action at this time.
0 commit comments