From a9819907ed934c94245dd6a42466824ebfcb5fa3 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 13:08:49 +0200 Subject: [PATCH] Add namespaced item renderer class loader refs #7642 --- library/Icinga/Web/Menu.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index e95f14c88..056e2ff88 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -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);