You are here

public function CourseObject::setCourse in Course 3.x

Same name and namespace in other branches
  1. 8.3 src/Entity/CourseObject.php \Drupal\course\Entity\CourseObject::setCourse()
  2. 8.2 src/Entity/CourseObject.php \Drupal\course\Entity\CourseObject::setCourse()

Set the Course for this CourseObject.

Parameters

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

Return value

CourseObject

File

src/Entity/CourseObject.php, line 717

Class

CourseObject
Parent abstract base class of all course objects.

Namespace

Drupal\course\Entity

Code

public function setCourse($course) {
  if (is_numeric($course)) {
    $this
      ->setOption('cid', $course);
  }
  else {
    $this
      ->setOption('cid', $course
      ->id());
  }
  return $this;
}