From 83cfcef85c98a9dadf155b38de53ccedaedcd38a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 28 Oct 2014 15:13:06 +0100 Subject: [PATCH] Add EnableModuleStep refs #7163 --- library/Icinga/Web/Setup/EnableModuleStep.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 library/Icinga/Web/Setup/EnableModuleStep.php diff --git a/library/Icinga/Web/Setup/EnableModuleStep.php b/library/Icinga/Web/Setup/EnableModuleStep.php new file mode 100644 index 000000000..796049734 --- /dev/null +++ b/library/Icinga/Web/Setup/EnableModuleStep.php @@ -0,0 +1,54 @@ +availableDirs = $availableDirs; + $this->moduleName = $moduleName; + } + + public function apply() + { + try { + $moduleManager = Icinga::app()->getModuleManager(); + $moduleManager->detectInstalledModules($this->availableDirs); + $moduleManager->enableModule($this->moduleName); + } catch (Exception $e) { + $this->error = $e; + return false; + } + + $this->error = false; + return true; + } + + public function getSummary() + { + // Enabling a module is like a implicit action, which does not need to be shown to the user... + } + + public function getReport() + { + if ($this->error === false) { + return '

' . sprintf(t('Module "%s" has been successfully enabled.'), $this->moduleName) . '

'; + } elseif ($this->error !== null) { + $message = t('Module "%s" could not be enabled. An error occured:'); + return '

' . sprintf($message, $this->moduleName) . '

' + . '

' . $this->error->getMessage() . '

'; + } + } +}