public function getAllSubpages($pageId)
    {
        $results = array();
        //Services
        $melisTree = $this->serviceLocator->get('MelisEngineTree');
        $pagePub   = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
        $pageSave  = $this->getServiceLocator()->get('MelisEngineTablePageSaved');

        $pageSearchType = null;
        $pages = $melisTree->getPageChildren($pageId,2);
        
        
        if($pages)
        {
            $rpages = $pages->toArray();
            
            foreach ($rpages as $page)
            {
                $pageStat = $page['page_status'] ?? null;
                //if the page is published
                if($pageStat){
                    $pageData       = $pagePub->getEntryById($page['tree_page_id'])->current();
                    $pageSearchType = $pageData->page_search_type ?? null;
                }
                //if the page is unpublished
                else{
                    $pageData = $pageSave->getEntryById($page['tree_page_id'])->current();
                    //if the unpublishedData is not present in page_saved table
                    if(!$pageData){
                        //Get the pageData in page_published table
                        $pageData = $pagePub->getEntryById($page['tree_page_id'])->current();
                    }
                    $pageSearchType = $pageData->page_search_type ?? null;
                }

                $tmp = $this->formatPageInArray($page,$pageSearchType);
                $children = $this->getAllSubpages($page['tree_page_id'] ?? null);

                if (!empty($children))
                    $tmp['pages'] = $children;

                $results[] = $tmp;
            }
        }
        return $results;
    }
public function getAllSubpages($pageId)
    {
        $results = array();
        //Services
        $melisTree = $this->serviceLocator->get('MelisEngineTree');
        $pagePub   = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
        $pageSave  = $this->getServiceLocator()->get('MelisEngineTablePageSaved');

        $pageSearchType = null;
        $pages = $melisTree->getPageChildren($pageId,2);
        
        
        if($pages)
        {
            $rpages = $pages->toArray();
            
            foreach ($rpages as $page)
            {
                $pageStat = $page['page_status'] ?? null;
                //if the page is published
                if($pageStat){
                    $pageData       = $pagePub->getEntryById($page['tree_page_id'])->current();
                    $pageSearchType = $pageData->page_search_type ?? null;
                }
                //if the page is unpublished
                else{
                    $pageData = $pageSave->getEntryById($page['tree_page_id'])->current();
                    //if the unpublishedData is not present in page_saved table
                    if(!$pageData){
                        //Get the pageData in page_published table
                        $pageData = $pagePub->getEntryById($page['tree_page_id'])->current();
                    }
                    $pageSearchType = $pageData->page_search_type ?? null;
                }

                $tmp = $this->formatPageInArray($page,$pageSearchType);
                $children = $this->getAllSubpages($page['tree_page_id'] ?? null);

                if (!empty($children))
                    $tmp['pages'] = $children;

                $results[] = $tmp;
            }
        }
        return $results;
    }
public function getAllSubpages ( $ pageId ) { $ results = array ( ) ; //Services $ melisTree = $ this -> serviceLocator -> get ( 'MelisEngineTree' ) ; $ pagePub = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePagePublished' ) ; $ pageSave = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageSaved' ) ; $ pageSearchType = null ; $ pages = $ melisTree -> getPageChildren ( $ pageId , 2 ) ; if ( $ pages ) { $ rpages = $ pages -> toArray ( ) ; foreach ( $ rpages as $ page ) { $ pageStat = $ page [ 'page_status' ] ?? null ; //if the page is published if ( $ pageStat ) { $ pageData = $ pagePub -> getEntryById ( $ page [ 'tree_page_id' ] ) -> current ( ) ; $ pageSearchType = $ pageData -> page_search_type ?? null ; } //if the page is unpublished else { $ pageData = $ pageSave -> getEntryById ( $ page [ 'tree_page_id' ] ) -> current ( ) ; //if the unpublishedData is not present in page_saved table if ( ! $ pageData ) { //Get the pageData in page_published table $ pageData = $ pagePub -> getEntryById ( $ page [ 'tree_page_id' ] ) -> current ( ) ; } $ pageSearchType = $ pageData -> page_search_type ?? null ; } $ tmp = $ this -> formatPageInArray ( $ page , $ pageSearchType ) ; $ children = $ this -> getAllSubpages ( $ page [ 'tree_page_id' ] ?? null ) ; if ( ! empty ( $ children ) ) $ tmp [ 'pages' ] = $ children ; $ results [ ] = $ tmp ; } } return $ results ; }
Get all Subpages including published and unplublished
@param $pageId
@return array
Get all Subpages including published and unplublished