You are here

public function Course::getTracker in Course 3.x

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

Get the course tracker for this course/user.

Return value

CourseEnrollment

Deprecated

use getEnrollment()

File

src/Entity/Course.php, line 107

Class

Course
Defines the Course entity class.

Namespace

Drupal\course\Entity

Code

public function getTracker(AccountInterface $account) {
  $entities = \Drupal::entityTypeManager()
    ->getStorage('course_enrollment')
    ->loadByProperties([
    'cid' => $this
      ->id(),
    'uid' => $account
      ->id(),
  ]);
  if ($entities) {
    return reset($entities);
  }
  return FALSE;
}