original_string: public function from_legacy_event_to_data(\calendar_event $legacyevent) {
          $legacyevent->count_repeats();
          $data = $legacyevent->properties();
          $data->timedurationuntil = $legacyevent->timestart + $legacyevent->timeduration;
          $data->duration = (empty($legacyevent->timeduration)) ? 0 : 1;
  
          if ($legacyevent->eventtype == 'group') {
              // Set up the correct value for the to display on the form.
              $data->groupid = $legacyevent->groupid;
              $data->groupcourseid = $legacyevent->courseid;
          }
          if ($legacyevent->eventtype == 'course') {
              // Set up the correct value for the to display on the form.
              $data->courseid = $legacyevent->courseid;
          }
          $data->description = [
              'text' => $data->description,
              'format' => $data->format
          ];
  
          // We don't want to return the context because it's not a
          // form value and breaks the validation.
          if (isset($data->context)) {
              unset($data->context);
          }
  
          return $data;
      }
code: public function from_legacy_event_to_data(\calendar_event $legacyevent) {
          $legacyevent->count_repeats();
          $data = $legacyevent->properties();
          $data->timedurationuntil = $legacyevent->timestart + $legacyevent->timeduration;
          $data->duration = (empty($legacyevent->timeduration)) ? 0 : 1;
  
          if ($legacyevent->eventtype == 'group') {
              // Set up the correct value for the to display on the form.
              $data->groupid = $legacyevent->groupid;
              $data->groupcourseid = $legacyevent->courseid;
          }
          if ($legacyevent->eventtype == 'course') {
              // Set up the correct value for the to display on the form.
              $data->courseid = $legacyevent->courseid;
          }
          $data->description = [
              'text' => $data->description,
              'format' => $data->format
          ];
  
          // We don't want to return the context because it's not a
          // form value and breaks the validation.
          if (isset($data->context)) {
              unset($data->context);
          }
  
          return $data;
      }
code_tokens: public function from_legacy_event_to_data ( \ calendar_event $ legacyevent ) { $ legacyevent -> count_repeats ( ) ; $ data = $ legacyevent -> properties ( ) ; $ data -> timedurationuntil = $ legacyevent -> timestart + $ legacyevent -> timeduration ; $ data -> duration = ( empty ( $ legacyevent -> timeduration ) ) ? 0 : 1 ; if ( $ legacyevent -> eventtype == 'group' ) { // Set up the correct value for the to display on the form. $ data -> groupid = $ legacyevent -> groupid ; $ data -> groupcourseid = $ legacyevent -> courseid ; } if ( $ legacyevent -> eventtype == 'course' ) { // Set up the correct value for the to display on the form. $ data -> courseid = $ legacyevent -> courseid ; } $ data -> description = [ 'text' => $ data -> description , 'format' => $ data -> format ] ; // We don't want to return the context because it's not a // form value and breaks the validation. if ( isset ( $ data -> context ) ) { unset ( $ data -> context ) ; } return $ data ; }
docstring: Generate the appropriate data for the form from a legacy event.
  
  @param \calendar_event $legacyevent
  @return stdClass
docstring_tokens: Generate the appropriate data for the form from a legacy event .