data = $data; } public function apply() { $instanceConfig = $this->data['instanceConfig']; $instanceName = $instanceConfig['name']; unset($instanceConfig['name']); try { Config::fromArray(array($instanceName => $instanceConfig)) ->setConfigFile(Config::resolvePath('modules/monitoring/instances.ini')) ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; } $this->error = false; return true; } public function getSummary() { $pageTitle = '

' . mt('monitoring', 'Monitoring Instance', 'setup.page.title') . '

'; if (isset($this->data['instanceConfig']['host'])) { $pipeHtml = '

' . sprintf( mt( 'monitoring', 'Icinga Web 2 will use the named pipe located on a remote machine at "%s" to send commands' . ' to your monitoring instance by using the connection details listed below:' ), $this->data['instanceConfig']['path'] ) . '

'; $pipeHtml .= '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . mt('monitoring', 'Remote Host') . '' . $this->data['instanceConfig']['host'] . '
' . mt('monitoring', 'Remote SSH Port') . '' . $this->data['instanceConfig']['port'] . '
' . mt('monitoring', 'Remote SSH User') . '' . $this->data['instanceConfig']['user'] . '
'; } else { $pipeHtml = '

' . sprintf( mt( 'monitoring', 'Icinga Web 2 will use the named pipe located at "%s"' . ' to send commands to your monitoring instance.' ), $this->data['instanceConfig']['path'] ) . '

'; } return $pageTitle . '
' . $pipeHtml . '
'; } public function getReport() { if ($this->error === false) { $message = mt('monitoring', 'Monitoring instance configuration has been successfully created: %s'); return '

' . sprintf($message, Config::resolvePath('modules/monitoring/instances.ini')) . '

'; } elseif ($this->error !== null) { $message = mt( 'monitoring', 'Monitoring instance configuration could not be written to: %s; An error occured:' ); return '

' . sprintf($message, Config::resolvePath('modules/monitoring/instances.ini')) . '

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

'; } } }