skipOuterElement = $skipOuterElement;
        $this->iterator = $navigation->getIterator();
        $this->navigation = $navigation;
        $this->content = array();
    }
    /**
     * {@inheritdoc}
     */
    public function setElementTag($tag)
    {
        $this->elementTag = $tag;
        return $this;
    }
    /**
     * {@inheritdoc}
     */
    public function getElementTag()
    {
        return $this->elementTag ?: static::OUTER_ELEMENT_TAG;
    }
    /**
     * {@inheritdoc}
     */
    public function setCssClass($class)
    {
        $this->cssClass = $class;
        return $this;
    }
    /**
     * {@inheritdoc}
     */
    public function getCssClass()
    {
        return $this->cssClass;
    }
    /**
     * {@inheritdoc}
     */
    public function setHeading($heading)
    {
        $this->heading = $heading;
        return $this;
    }
    /**
     * {@inheritdoc}
     */
    public function getHeading()
    {
        return $this->heading;
    }
    /**
     * Return the view
     *
     * @return View
     */
    public function view()
    {
        if ($this->view === null) {
            $this->setView(Icinga::app()->getViewRenderer()->view);
        }
        return $this->view;
    }
    /**
     * Set the view
     *
     * @param   View    $view
     *
     * @return  $this
     */
    public function setView(View $view)
    {
        $this->view = $view;
        return $this;
    }
    /**
     * {@inheritdoc}
     */
    public function getChildren()
    {
        return new static($this->current()->getChildren(), $this->skipOuterElement);
    }
    /**
     * {@inheritdoc}
     */
    public function hasChildren()
    {
        return $this->current()->hasChildren();
    }
    /**
     * {@inheritdoc}
     *
     * @return  NavigationItem
     */
    public function current()
    {
        return $this->iterator->current();
    }
    /**
     * {@inheritdoc}
     */
    public function key()
    {
        return $this->iterator->key();
    }
    /**
     * {@inheritdoc}
     */
    public function next()
    {
        $this->iterator->next();
    }
    /**
     * {@inheritdoc}
     */
    public function rewind()
    {
        $this->iterator->rewind();
        if (! $this->skipOuterElement) {
            $this->content[] = $this->beginMarkup();
        }
    }
    /**
     * {@inheritdoc}
     */
    public function valid()
    {
        $valid = $this->iterator->valid();
        if (! $this->skipOuterElement && !$valid) {
            $this->content[] = $this->endMarkup();
        }
        return $valid;
    }
    /**
     * Return the opening markup for the navigation
     *
     * @return  string
     */
    public function beginMarkup()
    {
        $content = array();
        $content[] = sprintf(
            '<%s%s role="navigation">',
            $this->getElementTag(),
            $this->getCssClass() !== null ? ' class="' . $this->getCssClass() . '"' : ''
        );
        if (($heading = $this->getHeading()) !== null) {
            $content[] = sprintf(
                '