You are here

public function Course::getObjects in Course 8.3

Same name and namespace in other branches
  1. 8.2 src/Entity/Course.php \Drupal\course\Entity\Course::getObjects()
  2. 3.x src/Entity/Course.php \Drupal\course\Entity\Course::getObjects()

Get the course objects in this course.

Return value

CourseObject[] An array of course objects.

1 call to Course::getObjects()
Course::setActive in src/Entity/Course.php
Set the active CourseObject in this Course.

File

src/Entity/Course.php, line 218

Class

Course
Defines the Course entity class.

Namespace

Drupal\course\Entity

Code

public function getObjects() {
  if (empty($this->courseObjects)) {
    $efq = \Drupal::entityQuery('course_object');
    $result = $efq
      ->condition('cid', $this
      ->id())
      ->sort('weight')
      ->execute();
    if (!empty($result)) {
      $this->courseObjects = \Drupal::entityTypeManager()
        ->getStorage('course_object')
        ->loadMultiple($result);
    }
  }
  return $this->courseObjects;
}