original_string: private function mapFolders(SS_List $folders, $searchQuery=null) {
          $result=array();
          
          foreach($folders as $folder) {
              if(!empty($searchQuery) && $searchQuery!==false) {
                  $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
                  if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) {
                      $searchEngine=new $searchEngine();
                  }else {
                      //Class is missing or invalid so fallback to the default
                      $searchEngine=new DefaultCodeBankSearchEngine();
                  }
                  
                  $snippets=$searchEngine->doSnippetSearch($searchQuery, false, $folder->ID);
              }else {
                  $snippets=$folder->Snippets();
              }
              
              $snippets=$this->overviewList($snippets, 'Title', 'ID', 'LanguageID');
              
              if(!empty($searchQuery) && $searchQuery!==false && count($snippets)==0) {
                  continue;
              }
              
              $result[]=array(
                              'id'=>$folder->ID,
                              'name'=>$folder->Name,
                              'languageID'=>$folder->LanguageID,
                              'folders'=>$this->mapFolders($folder->Folders(), $searchQuery),
                              'snippets'=>$snippets
                          );
          }
          
          return $result;
      }
code: private function mapFolders(SS_List $folders, $searchQuery=null) {
          $result=array();
          
          foreach($folders as $folder) {
              if(!empty($searchQuery) && $searchQuery!==false) {
                  $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
                  if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) {
                      $searchEngine=new $searchEngine();
                  }else {
                      //Class is missing or invalid so fallback to the default
                      $searchEngine=new DefaultCodeBankSearchEngine();
                  }
                  
                  $snippets=$searchEngine->doSnippetSearch($searchQuery, false, $folder->ID);
              }else {
                  $snippets=$folder->Snippets();
              }
              
              $snippets=$this->overviewList($snippets, 'Title', 'ID', 'LanguageID');
              
              if(!empty($searchQuery) && $searchQuery!==false && count($snippets)==0) {
                  continue;
              }
              
              $result[]=array(
                              'id'=>$folder->ID,
                              'name'=>$folder->Name,
                              'languageID'=>$folder->LanguageID,
                              'folders'=>$this->mapFolders($folder->Folders(), $searchQuery),
                              'snippets'=>$snippets
                          );
          }
          
          return $result;
      }
code_tokens: private function mapFolders ( SS_List $ folders , $ searchQuery = null ) { $ result = array ( ) ; foreach ( $ folders as $ folder ) { if ( ! empty ( $ searchQuery ) && $ searchQuery !== false ) { $ searchEngine = Config :: inst ( ) -> get ( 'CodeBank' , 'snippet_search_engine' ) ; if ( $ searchEngine && class_exists ( $ searchEngine ) && in_array ( 'ICodeBankSearchEngine' , class_implements ( $ searchEngine ) ) ) { $ searchEngine = new $ searchEngine ( ) ; } else { //Class is missing or invalid so fallback to the default $ searchEngine = new DefaultCodeBankSearchEngine ( ) ; } $ snippets = $ searchEngine -> doSnippetSearch ( $ searchQuery , false , $ folder -> ID ) ; } else { $ snippets = $ folder -> Snippets ( ) ; } $ snippets = $ this -> overviewList ( $ snippets , 'Title' , 'ID' , 'LanguageID' ) ; if ( ! empty ( $ searchQuery ) && $ searchQuery !== false && count ( $ snippets ) == 0 ) { continue ; } $ result [ ] = array ( 'id' => $ folder -> ID , 'name' => $ folder -> Name , 'languageID' => $ folder -> LanguageID , 'folders' => $ this -> mapFolders ( $ folder -> Folders ( ) , $ searchQuery ) , 'snippets' => $ snippets ) ; } return $ result ; }
docstring: Maps the folder and its decendents through recurrsion
  @param {SS_List} $folders List of folders to be mapped
  @param {string} $searchQuery Search Query
  @return {array} Nested array of folder data
docstring_tokens: Maps the folder and its decendents through recurrsion