Simplify backend config

This commit is contained in:
Alexander A. Klimov 2017-11-27 10:32:01 +01:00
parent b17986c07e
commit 2d5f858da5
2 changed files with 8 additions and 8 deletions

View file

@ -18,7 +18,7 @@ class BackendForm extends ConfigForm
$this->addElements([
[
'text',
'graphite_web_url',
'graphite_url',
[
'required' => true,
'label' => $this->translate('Graphite Web URL'),
@ -28,7 +28,7 @@ class BackendForm extends ConfigForm
],
[
'text',
'graphite_web_user',
'graphite_user',
[
'label' => $this->translate('Graphite Web user'),
'description' => $this->translate(
@ -39,7 +39,7 @@ class BackendForm extends ConfigForm
],
[
'password',
'graphite_web_password',
'graphite_password',
[
'renderPassword' => true,
'label' => $this->translate('Graphite Web password'),

View file

@ -61,14 +61,14 @@ trait GraphingTrait
if (static::$metricsDataSource === null) {
$config = Config::module('graphite');
$graphite = $config->getSection('graphite');
if (! isset($graphite->web_url)) {
throw new ConfigurationError('Missing "graphite.web_url" in "%s"', $config->getConfigFile());
if (! isset($graphite->url)) {
throw new ConfigurationError('Missing "graphite.url" in "%s"', $config->getConfigFile());
}
static::$metricsDataSource = new MetricsDataSource(
(new GraphiteWebClient(Url::fromPath($graphite->web_url)))
->setUser($graphite->web_user)
->setPassword($graphite->web_password)
(new GraphiteWebClient(Url::fromPath($graphite->url)))
->setUser($graphite->user)
->setPassword($graphite->password)
);
}