setOptions($options); } } /** * Set the given options * * @param array $options * * @return $this */ public function setOptions(array $options) { foreach ($options as $name => $value) { $setter = 'set' . String::cname($name); if (method_exists($this, $setter)) { $this->$setter($value); } } } /** * Set the view * * @param View $view * * @return $this */ public function setView(View $view) { $this->view = $view; return $this; } /** * Return the view * * @return View */ public function view() { if ($this->view === null) { $this->setView(Icinga::app()->getViewRenderer()->view); } return $this->view; } /** * Set the link target * * @param string $target * * @return $this */ public function setTarget($target) { $this->target = $target; return $this; } /** * Return the link target * * @return string */ public function getTarget() { return $this->target; } /** * Render the given navigation item as HTML anchor * * @param NavigationItem $item * * @return string */ public function render(NavigationItem $item) { $label = $this->view()->escape($item->getLabel()); if (($icon = $item->getIcon()) !== null) { $label = $this->view()->icon($icon) . $label; } if (($url = $item->getUrl()) !== null) { $content = sprintf( '%s', $this->view()->propertiesToString($item->getAttributes()), $this->view()->url($url, $item->getUrlParameters()), $this->target ? ' target="' . $this->view()->escape($this->target) . '"' : '', $label ); } else { $content = sprintf( '<%1$s%2$s>%3$s', $item::LINK_ALTERNATIVE, $this->view()->propertiesToString($item->getAttributes()), $label ); } return $content; } }