mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
RecursiveNavigationRenderer: Allow to enforce the standard item renderer
This commit is contained in:
parent
8c8af9cd50
commit
14ae04b631
@ -8,6 +8,7 @@ use RecursiveIteratorIterator;
|
|||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Web\Navigation\Navigation;
|
use Icinga\Web\Navigation\Navigation;
|
||||||
use Icinga\Web\Navigation\NavigationItem;
|
use Icinga\Web\Navigation\NavigationItem;
|
||||||
|
use Icinga\Web\Navigation\Renderer\NavigationItemRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer for multi level navigation
|
* Renderer for multi level navigation
|
||||||
@ -25,6 +26,13 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N
|
|||||||
*/
|
*/
|
||||||
protected $content;
|
protected $content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to use the standard item renderer
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $useStandardRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new RecursiveNavigationRenderer
|
* Create a new RecursiveNavigationRenderer
|
||||||
*
|
*
|
||||||
@ -39,6 +47,29 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to use the standard navigation item renderer
|
||||||
|
*
|
||||||
|
* @param bool $state
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setUseStandardItemRenderer($state = true)
|
||||||
|
{
|
||||||
|
$this->useStandardRenderer = (bool) $state;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether to use the standard navigation item renderer
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUseStandardItemRenderer()
|
||||||
|
{
|
||||||
|
return $this->useStandardRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -131,7 +162,14 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N
|
|||||||
/** @var NavigationItem $item */
|
/** @var NavigationItem $item */
|
||||||
if ($item->shouldRender()) {
|
if ($item->shouldRender()) {
|
||||||
$this->content[] = $this->getInnerIterator()->beginItemMarkup($item);
|
$this->content[] = $this->getInnerIterator()->beginItemMarkup($item);
|
||||||
$this->content[] = $item->render();
|
|
||||||
|
if ($this->getUseStandardItemRenderer()) {
|
||||||
|
$renderer = new NavigationItemRenderer();
|
||||||
|
$this->content[] = $renderer->render($item);
|
||||||
|
} else {
|
||||||
|
$this->content[] = $item->render();
|
||||||
|
}
|
||||||
|
|
||||||
if (! $item->hasChildren()) {
|
if (! $item->hasChildren()) {
|
||||||
$this->content[] = $this->getInnerIterator()->endItemMarkup();
|
$this->content[] = $this->getInnerIterator()->endItemMarkup();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user