CustomVariables: allow to instantiate from cache

This commit is contained in:
Thomas Gelf 2016-06-30 10:42:52 +02:00
parent b09c4f8ef0
commit f288ddaf95
1 changed files with 12 additions and 0 deletions

View File

@ -133,6 +133,18 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
return $vars; return $vars;
} }
public static function forStoredRows($rows)
{
$vars = new CustomVariables;
foreach ($rows as $row) {
$vars->vars[$row->varname] = CustomVariable::fromDbRow($row);
}
$vars->refreshIndex();
$vars->setUnmodified();
return $vars;
}
public function storeToDb(IcingaObject $object) public function storeToDb(IcingaObject $object)
{ {
$db = $object->getDb(); $db = $object->getDb();