Пример #1
0
    /**
     * Returns the root container of the given page
     *
     * When rendering a container, the render method still store the given
     * container as the root container, and unset it when done rendering. This
     * makes sure finder methods will not traverse above the container given
     * to the render method.
     *
     * @param  Zend_Navigaiton_Page $page  page to find root for
     * @return \Zend\Navigation\Container   the root container of the given page
     */
    protected function _findRoot(AbstractPage $page)
    {
        if ($this->_root) {
            return $this->_root;
        }

        $root = $page;

        while ($parent = $page->getParent()) {
            $root = $parent;
            if ($parent instanceof AbstractPage) {
                $page = $parent;
            } else {
                break;
            }
        }

        return $root;
    }