File tree 2 files changed +49
-0
lines changed
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,49 @@ client:
403
403
plugins :
404
404
- ' acme_plugin'
405
405
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
+
406
449
Authentication
407
450
--------------
408
451
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.
113
113
plugins :
114
114
# Can reference a globally configured plugin service
115
115
- ' 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'
116
122
# Can configure a plugin customized for this client
117
123
- cache :
118
124
cache_pool : ' my_other_pool'
You can’t perform that action at this time.
0 commit comments