Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Implement Moodle type hook to let plugins extend its configuration #254

Open
danowar2k opened this issue Aug 30, 2023 · 2 comments
Open

Comments

@danowar2k
Copy link

danowar2k commented Aug 30, 2023

For now you need users to write config.local.php inside the plugin's directory, which isn't a very clean way of configuring it.

Nicer for plugin developers who want to provide additional configuration for better plugin compatibility would be to add a hook to config.php, e.g. here:

private function __construct() {
    $config = include dirname(__DIR__) . '/config/config.php';

    $pluginswithfunction = get_plugins_with_function('tool_mergeusers_extend_config', 'lib.php');
    foreach ($pluginswithfunction as $plugins) {
        foreach ($plugins as $function) {
           try {
              $config = $function($config);
           } catch (Throwable $e) {
           debugging("Exception calling '$function'", DEBUG_DEVELOPER, $e->getTrace());
        }
    }
    $this->config = $config;
}

This way each plugin could decide what to add or even write special functions that would be called when merging.

@jpahullo
Copy link
Owner

jpahullo commented Aug 31, 2023 via email

@jpahullo
Copy link
Owner

jpahullo commented Dec 1, 2023

Hi @danowar2k ,

Would you mind you could provide a PR for this?

I am very interested on this.

Thanks a lot for reporting,

Jordi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants