Skip to content

Commit

Permalink
Explain PluginConfigurator
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Nov 23, 2024
1 parent 67c88ee commit 0ab3269
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
43 changes: 43 additions & 0 deletions integrations/symfony-bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.


.. 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
--------------

Expand Down
6 changes: 6 additions & 0 deletions integrations/symfony-full-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 0ab3269

Please sign in to comment.