From a8dd9c933d579d1a972baef8930dcbc21ee77f6f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 24 Oct 2014 13:52:26 +0200 Subject: [PATCH] Add the possibility for modules to provide a setup wizard refs #7163 --- library/Icinga/Application/Modules/Module.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index b1b051a6c..c81a7f9e5 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -18,6 +18,7 @@ use Icinga\Web\Hook; use Icinga\Web\Menu; use Icinga\Web\Widget; use Icinga\Web\Widget\Dashboard\Pane; +use Icinga\Web\Setup\SetupWizard; use Icinga\Util\File; use Icinga\Exception\ProgrammingError; use Icinga\Exception\IcingaException; @@ -134,6 +135,13 @@ class Module */ private $configTabs = array(); + /** + * Provided setup wizard + * + * @var string + */ + private $setupWizard; + /** * Icinga application * @@ -642,6 +650,31 @@ class Module return $tabs; } + /** + * Whether this module provides a setup wizard + * + * @return bool + */ + public function providesSetupWizard() + { + $this->launchConfigScript(); + if (class_exists($this->setupWizard)) { + $wizard = new $this->setupWizard; + return $wizard instanceof SetupWizard; + } + + return false; + } + + /** + * Return this module's setup wizard + * + * @return SetupWizard + */ + public function getSetupWizard() + { + return new $this->setupWizard; + } /** * Provide a named permission @@ -705,6 +738,19 @@ class Module return $this; } + /** + * Provide a setup wizard + * + * @param string $className The name of the class + * + * @return self + */ + protected function provideSetupWizard($className) + { + $this->setupWizard = $className; + return $this; + } + /** * Register new namespaces on the autoloader *