bnomei/kirby3-doctor

Allow plugins to define checks

fabianmichael opened this issue · 0 comments

As the plugin allows to define custom checks in the config.php file, it would be a great addition to give plugins access to that functionality as well. A thumbnail generator could check is the driver works or necessary CLI tools are available, plugins accessing third-party APIs could check whether the API keys are valid etc.

Kirby’s plugin method can hold custom parameters, the implementation could be done as simple as follows:

Kirby::plugin('my/plugin', [
  'bnomei.doctor.checks' => [
    "MyNamespace\\MyClass" => true, // enable new
  ],
]);

The Doctor class could load the checks defined by plugins pretty easily:

$pluginChecks = [];

foreach (kirby()->plugins() as $plugin) {
  $pluginChecks = array_merge($pluginChecks, $plugin->extends()['bnomei.doctor.checks'] ?? []);
}