Skip to content

Commit

Permalink
NavigationController: Add method getConfigPath()
Browse files Browse the repository at this point in the history
refs #10246
  • Loading branch information
Johannes Meyer committed Sep 29, 2015
1 parent 5d4f7cf commit 5657041
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions application/controllers/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,35 @@ protected function listItemTypes()
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
*/
Expand Down

0 comments on commit 5657041

Please sign in to comment.