Use Config helper (#10339)

remove usage of global variable
This commit is contained in:
Tony Murray
2019-06-23 00:29:12 -05:00
committed by GitHub
parent 342acf50f1
commit f3ba8947f7
367 changed files with 1589 additions and 1857 deletions
+3 -10
View File
@@ -192,20 +192,13 @@ class Device extends BaseModel
public function loadOs($force = false)
{
global $config;
$yaml_file = base_path('/includes/definitions/' . $this->os . '.yaml');
if ((empty($config['os'][$this->os]['definition_loaded']) || $force) && file_exists($yaml_file)) {
if ((!\LibreNMS\Config::getOsSetting($this->os, 'definition_loaded') || $force) && file_exists($yaml_file)) {
$os = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($yaml_file));
if (isset($config['os'][$this->os])) {
$config['os'][$this->os] = array_replace_recursive($os, $config['os'][$this->os]);
} else {
$config['os'][$this->os] = $os;
}
$config['os'][$this->os]['definition_loaded'] = true;
\LibreNMS\Config::set("os.$this->os", array_replace_recursive($os, \LibreNMS\Config::get("os.$this->os", [])));
\LibreNMS\Config::set("os.$this->os.definition_loaded", true);
}
}