bnomei / kirby3-doctor

Plugin to check health of your CMS installation
https://forum.getkirby.com/t/kirby3-doctor-check-health-of-kirby-installation/23579
MIT License
19 stars 1 forks source link

Allow plugins to define checks #4

Closed fabianmichael closed 5 years ago

fabianmichael commented 5 years ago

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'] ?? []);
}