NavigationController: Add method getConfigPath()

refs #10246
This commit is contained in:
Johannes Meyer 2015-09-29 17:08:53 +02:00
parent 5d4f7cf2c0
commit 565704141c
1 changed files with 29 additions and 0 deletions

View File

@ -62,6 +62,35 @@ class NavigationController extends Controller
return $types; return $types;
} }
/**
* Return the path to the configuration file for the given navigation item type and user
*
* @param string $type
* @param string $username
*
* @return string
*
* @throws IcingaException In case the given type is unknown
*/
protected function getConfigPath($type, $username = null)
{
if (isset($this->defaultItemTypes[$type])) {
$options = $this->defaultItemTypes[$type];
} elseif (isset($this->moduleItemTypes[$type])) {
$options = $this->moduleItemTypes[$type];
} else {
throw new IcingaException('Invalid navigation item type %s provided', $type);
}
if (isset($options['config'])) {
$filename = $options['config'] . '.ini';
} else {
$filename = $type . 's.ini';
}
return Config::resolvePath(($username ? "preferences/$username/" : 'navigation/') . $filename);
}
/** /**
* Show the current user a list of his/her navigation items * Show the current user a list of his/her navigation items
*/ */