function Course::getEnrollment in Course 8.2
Same name and namespace in other branches
- 8.3 src/Entity/Course.php \Drupal\course\Entity\Course::getEnrollment()
- 3.x src/Entity/Course.php \Drupal\course\Entity\Course::getEnrollment()
Load an enrollment.
@todo maybe move to CourseStorage
Parameters
AccountInterface $account:
Return value
\Drupal\course\Entity\CourseEnrollment
1 call to Course::getEnrollment()
- Course::enroll in src/
Entity/ Course.php - Enroll a user in this course.
File
- src/
Entity/ Course.php, line 452
Class
- Course
- Defines the Course entity class.
Namespace
Drupal\course\EntityCode
function getEnrollment(AccountInterface $account) {
$entities = Drupal::entityTypeManager()
->getStorage('course_enrollment')
->loadByProperties([
'cid' => $this
->id(),
'uid' => $account
->id(),
]);
if ($entities) {
return reset($entities);
}
}