function _Course::__sleep

4.x _Course.php _Course::__sleep()
5.x _Course.php _Course::__sleep()

This is the magic method __sleep(). PHP will call this method any time this object is being serialized. It is supposed to return an array of all the variables which need to be serialized.

What we are doing in it is skipping any variables which we are not using or which do not need to be serialized. This will greatly reduce the size of the final serialized string.

It may not seem worth it at first, but consider that we may be serializing an entire degree plan, with a dozen groups, each with every course in the catalog. That could easily be 10,000+ courses which get serialized!

Return value

array

File

classes/_Course.php, line 2145

Class

_Course

Code

function __sleep() 
 {
  // This is supposed to return an array with the names
  // of the variables which are supposed to be serialized.

  $arr = array(
    "db_advised_courses_id", "random_id",
    "db_substitution_id_array", "db_unassign_transfer_id",
    "db_exclude", "array_index", "db_group_requirement_id", "array_valid_names",
    "data_entry_value",

    "subject_id", "course_num", "course_id", "requirement_type", "catalog_year",
    "min_hours", "max_hours", "repeat_hours", "bool_outdated_sub",

    "bool_taken", "term_id", "section_number", "grade", "quality_points",
    "bool_transfer", "institution_id", "institution_name", "course_transfer", "transfer_footnote",
    "substitution_footnote",

    "min_grade", "specified_repeats", "bool_specified_repeat", "required_on_branch_id",
    "assigned_to_group_id", "assigned_to_semester_num", "level_code", "req_by_degree_id",
    "assigned_to_degree_ids_array", "assigned_to_group_ids_array",

    "advised_hours", "bool_selected", "bool_advised_to_take", "bool_use_draft",
    "course_list_fulfilled_by",
    "bool_added_course", "group_list_unassigned",

    "details_by_degree_array",

    "display_status", "disp_for_group_id",
    "bool_hide_grade", "bool_ghost_hour",
    "bool_ghost_min_hour",
  );

  // Okay, remove any variables we are not using
  // from the array.
  $rtn = array();
  foreach ($arr as $var) 
   {
    if (isset($this->$var)) // This checks to see if we are using
     { // the variable or not.
      $rtn [] = $var;
    }
  }

  return $rtn;
}