You are here

public function Course::getTracker in Course 8.2

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

Get the course tracker for this course/user.

Return value

CourseEnrollment

1 call to Course::getTracker()
Course::isEnrolled in src/Entity/Course.php
Check if a user is enrolled.

File

src/Entity/Course.php, line 83

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;
}