You are here

public function CourseObject::setCourse in Course 6

Same name and namespace in other branches
  1. 7.2 includes/CourseObject.inc \CourseObject::setCourse()
  2. 7 includes/CourseObject.inc \CourseObject::setCourse()

Set the Course for this CourseObject.

Parameters

Course|int $course: A Course or node ID.

Return value

CourseObject

File

includes/course_object.core.inc, line 701

Class

CourseObject
Parent abstract base class of all course objects.

Code

public function setCourse($course) {
  if (is_numeric($course)) {
    $this
      ->setOption('nid', $course);
    $courseNode = node_load($course);
    $this->course = course_get_course($courseNode);
  }
  else {
    $this->course = $course;
    $this
      ->setOption('nid', $course
      ->getNode()->nid);
  }
  return $this;
}