Navigation: Add method render()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-03 15:04:07 +02:00
parent 9a725330fb
commit a930ea7f7a
1 changed files with 26 additions and 1 deletions

View File

@ -5,6 +5,7 @@ namespace Icinga\Web\Navigation;
use ArrayAccess;
use ArrayIterator;
use Exception;
use Countable;
use InvalidArgumentException;
use IteratorAggregate;
@ -14,6 +15,7 @@ use Icinga\Application\Logger;
use Icinga\Authentication\Auth;
use Icinga\Data\ConfigObject;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\IcingaException;
use Icinga\Exception\ProgrammingError;
use Icinga\Util\String;
@ -271,6 +273,16 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
return new RecursiveNavigationRenderer($this);
}
/**
* Return this navigation rendered to HTML
*
* @return string
*/
public function render()
{
return $this->getRenderer()->render();
}
/**
* Order this navigation's items
*
@ -394,5 +406,18 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
return $navigation;
}
}
/**
* Return this navigation rendered to HTML
*
* @return string
*/
public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
return IcingaException::describe($e);
}
}
}