From 4eb5f75c62056b6c9b19c156c52bac165b1169ba Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 17:04:46 +0200 Subject: [PATCH] Use default MenuItemRenderer as renderer if no custom renderer is set refs #7658 --- library/Icinga/Web/MenuRenderer.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/library/Icinga/Web/MenuRenderer.php b/library/Icinga/Web/MenuRenderer.php index 7d2cd5ad3..4dec9404e 100644 --- a/library/Icinga/Web/MenuRenderer.php +++ b/library/Icinga/Web/MenuRenderer.php @@ -4,6 +4,7 @@ namespace Icinga\Web; use Exception; +use Icinga\Web\Menu\MenuItemRenderer; use RecursiveIteratorIterator; use Icinga\Application\Logger; use Icinga\Web\Menu\PermittedMenuItemFilter; @@ -32,6 +33,11 @@ class MenuRenderer extends RecursiveIteratorIterator */ protected $useCustomRenderer = false; + /** + * @var MenuItemRenderer + */ + protected $defaultRenderer; + /** * Create a new MenuRenderer * @@ -45,6 +51,7 @@ class MenuRenderer extends RecursiveIteratorIterator } else { $this->url = Url::fromPath($url); } + $this->defaultRenderer = new MenuItemRenderer(); parent::__construct(new PermittedMenuItemFilter($menu), RecursiveIteratorIterator::CHILD_FIRST); } @@ -114,22 +121,8 @@ class MenuRenderer extends RecursiveIteratorIterator Logger::error('Could not invoke custom renderer. Exception: '. $e->getMessage()); } } - if ($child->getIcon() && strpos($child->getIcon(), '.') === false) { - return sprintf( - '%s', - $child->getUrl() ?: '#', - $child->getIcon(), - htmlspecialchars($child->getTitle()) - ); - } - return sprintf( - '%s%s', - $child->getUrl() ?: '#', - $child->getIcon() - ? ' ' - : '', - htmlspecialchars($child->getTitle()) - ); + + return $this->defaultRenderer->render($child); } /**