mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-05-28 04:34:57 -04:00
TemplateSet: load templates with set key
This commit is contained in:
parent
dc2d32a5fb
commit
b52f6ef97b
1 changed files with 9 additions and 4 deletions
|
|
@ -59,7 +59,7 @@ class TemplateSet
|
|||
public function extendEnumTemplates(& $enum)
|
||||
{
|
||||
foreach ($this->loadTemplates() as $key => $template) {
|
||||
$enum[sprintf('%s/%s', $this->name, $key)] = $template->getTitle();
|
||||
$enum[$key] = $template->getTitle();
|
||||
}
|
||||
|
||||
return $enum;
|
||||
|
|
@ -74,23 +74,28 @@ class TemplateSet
|
|||
{
|
||||
$dir = $this->basedir;
|
||||
$templates = array();
|
||||
if ($name !== null && strpos($name, '/') === false) {
|
||||
$name = $this->name . '/' . $name;
|
||||
}
|
||||
|
||||
foreach (new DirectoryIterator($dir) as $file) {
|
||||
if ($file->isDot()) continue;
|
||||
$filename = $file->getFilename();
|
||||
if (substr($filename, -5) === '.conf') {
|
||||
$tname = substr($filename, 0, -5);
|
||||
$key = $this->name . '/' . $tname;
|
||||
|
||||
if ($name !== null) {
|
||||
if ($name !== $tname) continue;
|
||||
if ($name !== $key) continue;
|
||||
}
|
||||
$templates[$this->name . '/' . $tname] = GraphTemplate::load(
|
||||
$templates[$key] = GraphTemplate::load(
|
||||
file_get_contents($file->getPathname())
|
||||
)->prefillFilterString($this->getBasePatterns());
|
||||
}
|
||||
}
|
||||
|
||||
if ($name !== null) {
|
||||
$name = $this->name . '/' . $name;
|
||||
|
||||
if (! array_key_exists($name, $templates)) {
|
||||
throw new NotFoundError(
|
||||
'The desired template "%s" doesn\'t exist',
|
||||
|
|
|
|||
Loading…
Reference in a new issue