Add config parameter from plugin

I’d like to extend a Kirby website by a small snippet. To keep everything together in one place I thought it is a good idea to create a small custom plugin including css file, blueprint and snippet.

This is working good so far, but to get everything going, at the moment I need to edit site/config/config.php and add a parameter value for another already used plugin for this to be aware of the new snippet ‘new-value’.

This looks like:

return [
   'old.plugin' => [
        'parameter' => ['value1', 'value2', 'new-value'],
    ],
];

But I’d like to remove the need to edit this file outside of the plugin folder if possible. I’d prefer to add the ‘new-value’ from within the new plugin. I thought this can be achived by keeping the config file as it is

return [
   'old.plugin' => [
        'parameter' => ['value1', 'value2'],
    ],
];

and use a hook in the new plugin like:

Kirby::plugin('new/plugin', [
    'hooks' => [
        'system.loadPlugins:after' => function () {
            kirby()->extend([
                'options' => [
                    'parameter'  => ['new-value']
                ]
            ], kirby()->plugin('old/plugin'));
        }
    ]
]);

But this doesn’t work. The hook is executed, but

option('old.plugin.parameter')

still just contains ‘value1’ and ‘value2’.

Any ideas how to get this solved just from within the new plugin?

Not really. You want this value to be available in the old plugin. But the hook is called after all plugins are already loaded, so I don’t think this can affect other plugins but only the current one.