element specific attributes
     *
     * @var array
     */
    protected $attributes = array();
    /**
     * View
     *
     * @var View|null
     */
    protected $view;
    /**
     * Set the view
     *
     * @param   View    $view
     *
     * @return  $this
     */
    public function setView(View $view)
    {
        $this->view = $view;
        return $this;
    }
    /**
     * Get the view
     *
     * @return View
     */
    public function getView()
    {
        if ($this->view === null) {
            $this->view = Icinga::app()->getViewRenderer()->view;
        }
        return $this->view;
    }
    /**
     * Renders the html content of a single menu item
     *
     * @param Menu $menu
     *
     * @return string
     */
    public function render(Menu $menu)
    {
        return $this->createLink($menu);
    }
    /**
     * Creates a menu item link element
     *
     * @param Menu $menu
     *
     * @return string
     */
    public function createLink(Menu $menu)
    {
        if ($menu->getIcon() && strpos($menu->getIcon(), '.') === false) {
            return sprintf(
                '%s',
                $menu->getUrl() ? : '#',
                $this->getAttributes(),
                $menu->getIcon(),
                $this->getView()->escape($menu->getTitle())
            );
        }
        return sprintf(
            '%s%s',
            $menu->getUrl() ? : '#',
            $this->getAttributes(),
            $menu->getIcon() ? ') . ') ' : '',
            $this->getView()->escape($menu->getTitle())
        );
    }
    /**
     * Returns  element specific attributes if present
     *
     * @return string
     */
    protected function getAttributes()
    {
        $attributes = '';
        $view = $this->getView();
        foreach ($this->attributes as $attribute => $value) {
            $attributes .= ' ' . $view->escape($attribute) . '="' . $view->escape($value) . '"';
        }
        return $attributes;
    }
}
 ' : '',
            $this->getView()->escape($menu->getTitle())
        );
    }
    /**
     * Returns  element specific attributes if present
     *
     * @return string
     */
    protected function getAttributes()
    {
        $attributes = '';
        $view = $this->getView();
        foreach ($this->attributes as $attribute => $value) {
            $attributes .= ' ' . $view->escape($attribute) . '="' . $view->escape($value) . '"';
        }
        return $attributes;
    }
}