src/Project.php
protected function resolveDocumentsMenu($items, $parentId = 'root')
    {
        /**
         * @var Menus\Menu $menu
         */
        $menu = $this->factory->getMenus()->add('project_sidebar_menu');

        foreach ($items as $item) {
            $link = '#';
            if (array_key_exists('document', $item)) {
            // remove .md extension if present
                $path = Str::endsWith($item[ 'document' ], '.md', false) ? Str::remove($item[ 'document' ], '.md') : $item[ 'document' ];
                $link = $this->factory->url($this, $this->ref, $path);
            } elseif (array_key_exists('href', $item)) {
                $link = $item[ 'href' ];
            }

            $id = md5($item[ 'name' ] . $link);

            $node = $menu->add($id, $item[ 'name' ], $parentId);
            $node->setAttribute('href', $link);
            $node->setAttribute('id', $id);

            if (isset($item[ 'icon' ])) {
                $node->setMeta('icon', $item[ 'icon' ]);
            }

            if (isset($item[ 'children' ])) {
                $this->resolveDocumentsMenu($item[ 'children' ], $id);
            }
        }

        return $menu;
    }
protected function resolveDocumentsMenu($items, $parentId = 'root')
    {
        /**
         * @var Menus\Menu $menu
         */
        $menu = $this->factory->getMenus()->add('project_sidebar_menu');

        foreach ($items as $item) {
            $link = '#';
            if (array_key_exists('document', $item)) {
            // remove .md extension if present
                $path = Str::endsWith($item[ 'document' ], '.md', false) ? Str::remove($item[ 'document' ], '.md') : $item[ 'document' ];
                $link = $this->factory->url($this, $this->ref, $path);
            } elseif (array_key_exists('href', $item)) {
                $link = $item[ 'href' ];
            }

            $id = md5($item[ 'name' ] . $link);

            $node = $menu->add($id, $item[ 'name' ], $parentId);
            $node->setAttribute('href', $link);
            $node->setAttribute('id', $id);

            if (isset($item[ 'icon' ])) {
                $node->setMeta('icon', $item[ 'icon' ]);
            }

            if (isset($item[ 'children' ])) {
                $this->resolveDocumentsMenu($item[ 'children' ], $id);
            }
        }

        return $menu;
    }
protected function resolveDocumentsMenu ( $ items , $ parentId = 'root' ) { /**
         * @var Menus\Menu $menu
         */ $ menu = $ this -> factory -> getMenus ( ) -> add ( 'project_sidebar_menu' ) ; foreach ( $ items as $ item ) { $ link = '#' ; if ( array_key_exists ( 'document' , $ item ) ) { // remove .md extension if present $ path = Str :: endsWith ( $ item [ 'document' ] , '.md' , false ) ? Str :: remove ( $ item [ 'document' ] , '.md' ) : $ item [ 'document' ] ; $ link = $ this -> factory -> url ( $ this , $ this -> ref , $ path ) ; } elseif ( array_key_exists ( 'href' , $ item ) ) { $ link = $ item [ 'href' ] ; } $ id = md5 ( $ item [ 'name' ] . $ link ) ; $ node = $ menu -> add ( $ id , $ item [ 'name' ] , $ parentId ) ; $ node -> setAttribute ( 'href' , $ link ) ; $ node -> setAttribute ( 'id' , $ id ) ; if ( isset ( $ item [ 'icon' ] ) ) { $ node -> setMeta ( 'icon' , $ item [ 'icon' ] ) ; } if ( isset ( $ item [ 'children' ] ) ) { $ this -> resolveDocumentsMenu ( $ item [ 'children' ] , $ id ) ; } } return $ menu ; }
Resolves and creates the documents menu from the parsed menu.yml

@param array       $items The array converted from yaml
@param string $parentId
@return \Docit\Core\Menus\Menu
Resolves and creates the documents menu from the parsed menu . yml