original_string: final protected function overviewList(SS_List $list, $labelField='Title', $idField='ID') {
          $result=array();
          $idFieldLower=strtolower($idField);
          $labelFieldLower=strtolower($labelField);
          
          
          $args=func_get_args();
          unset($args[0]);
          unset($args[1]);
          unset($args[2]);
          
          
          foreach($list as $item) {
              $obj=new stdClass();
              $obj->$idFieldLower=$item->$idField;
              $obj->$labelFieldLower=$item->$labelField;
              
              if(count($args)>0) {
                  foreach($args as $field) {
                      $fieldLower=strtolower($field);
                      
                      //If the field contains a dot assume relationship and loop through till field is found
                      if(strpos($field, '.')!==false) {
                          $fieldLower=str_replace('.', '-', $fieldLower);
                          $fieldBits=explode('.', $field);
                          
                          $value=$item;
                          for($i=0;$i<count($fieldBits);$i++) {
                              $fieldBit=$fieldBits[$i];
                              if($i==count($fieldBits)-1) {
                                  $value=$value->$fieldBit;
                              }else {
                                  $value=$value->$fieldBit();
                              }
                          }
                          
                          if(!is_object($value)) {
                              $obj->$fieldLower=$value;
                          }
                      }else {
                          $obj->$fieldLower=$item->$field;
                      }
                  }
              }
              
              $result[]=$obj;
          }
          
          
          return $result;
      }
code: final protected function overviewList(SS_List $list, $labelField='Title', $idField='ID') {
          $result=array();
          $idFieldLower=strtolower($idField);
          $labelFieldLower=strtolower($labelField);
          
          
          $args=func_get_args();
          unset($args[0]);
          unset($args[1]);
          unset($args[2]);
          
          
          foreach($list as $item) {
              $obj=new stdClass();
              $obj->$idFieldLower=$item->$idField;
              $obj->$labelFieldLower=$item->$labelField;
              
              if(count($args)>0) {
                  foreach($args as $field) {
                      $fieldLower=strtolower($field);
                      
                      //If the field contains a dot assume relationship and loop through till field is found
                      if(strpos($field, '.')!==false) {
                          $fieldLower=str_replace('.', '-', $fieldLower);
                          $fieldBits=explode('.', $field);
                          
                          $value=$item;
                          for($i=0;$i<count($fieldBits);$i++) {
                              $fieldBit=$fieldBits[$i];
                              if($i==count($fieldBits)-1) {
                                  $value=$value->$fieldBit;
                              }else {
                                  $value=$value->$fieldBit();
                              }
                          }
                          
                          if(!is_object($value)) {
                              $obj->$fieldLower=$value;
                          }
                      }else {
                          $obj->$fieldLower=$item->$field;
                      }
                  }
              }
              
              $result[]=$obj;
          }
          
          
          return $result;
      }
code_tokens: final protected function overviewList ( SS_List $ list , $ labelField = 'Title' , $ idField = 'ID' ) { $ result = array ( ) ; $ idFieldLower = strtolower ( $ idField ) ; $ labelFieldLower = strtolower ( $ labelField ) ; $ args = func_get_args ( ) ; unset ( $ args [ 0 ] ) ; unset ( $ args [ 1 ] ) ; unset ( $ args [ 2 ] ) ; foreach ( $ list as $ item ) { $ obj = new stdClass ( ) ; $ obj -> $ idFieldLower = $ item -> $ idField ; $ obj -> $ labelFieldLower = $ item -> $ labelField ; if ( count ( $ args ) > 0 ) { foreach ( $ args as $ field ) { $ fieldLower = strtolower ( $ field ) ; //If the field contains a dot assume relationship and loop through till field is found if ( strpos ( $ field , '.' ) !== false ) { $ fieldLower = str_replace ( '.' , '-' , $ fieldLower ) ; $ fieldBits = explode ( '.' , $ field ) ; $ value = $ item ; for ( $ i = 0 ; $ i < count ( $ fieldBits ) ; $ i ++ ) { $ fieldBit = $ fieldBits [ $ i ] ; if ( $ i == count ( $ fieldBits ) - 1 ) { $ value = $ value -> $ fieldBit ; } else { $ value = $ value -> $ fieldBit ( ) ; } } if ( ! is_object ( $ value ) ) { $ obj -> $ fieldLower = $ value ; } } else { $ obj -> $ fieldLower = $ item -> $ field ; } } } $ result [ ] = $ obj ; } return $ result ; }
docstring: Converts an SS_List into an array of items with and id and a title key
  @param {SS_List} $list List to parse
  @param {string} $labelField Label Field
  @param {string} $idField ID Field
  @param {string} ... Overloaded for additional fields, allows for silverstripe relation formatting ex: Relationship.Field the dot is replaced with a dash in the resulting object
  @return {array} Nested array of items, each item has an id and a title key
docstring_tokens: Converts an SS_List into an array of items with and id and a title key