Add namespaced item renderer class loader

refs #7642
This commit is contained in:
Alexander Fuhr 2015-04-20 13:08:49 +02:00
parent c76e4e3583
commit a9819907ed
1 changed files with 10 additions and 6 deletions

View File

@ -117,13 +117,17 @@ class Menu implements RecursiveIterator
foreach ($props as $key => $value) {
$method = 'set' . implode('', array_map('ucfirst', explode('_', strtolower($key))));
if ($key === 'renderer') {
$class = '\Icinga\Web\Menu\\' . $value;
if (!class_exists($class)) {
throw new ConfigurationError(
sprintf('ItemRenderer with class "%s" does not exist', $class)
);
if (class_exists($value)) {
$value = new $value;
} else {
$class = '\Icinga\Web\Menu\\' . $value;
if (!class_exists($class)) {
throw new ConfigurationError(
sprintf('ItemRenderer with class "%s" does not exist', $class)
);
}
$value = new $class;
}
$value = new $class;
}
if (method_exists($this, $method)) {
$this->{$method}($value);