public function CourseObject::getFulfillment in Course 8.2
Same name and namespace in other branches
- 8.3 src/Entity/CourseObject.php \Drupal\course\Entity\CourseObject::getFulfillment()
- 3.x src/Entity/CourseObject.php \Drupal\course\Entity\CourseObject::getFulfillment()
Get a user's fulfillment for this course object. If the user has not started this course object, a new, unsaved fulfillment will be return.
Parameters
stdClass $account: User account to get fulfillment for.
Return value
File
- src/
Entity/ CourseObject.php, line 620
Class
- CourseObject
- Parent abstract base class of all course objects.
Namespace
Drupal\course\EntityCode
public function getFulfillment(AccountInterface $account) {
$entities = \Drupal::entityTypeManager()
->getStorage('course_object_fulfillment')
->loadByProperties([
'coid' => $this
->id(),
'uid' => $account
->id(),
]);
if ($entities) {
return reset($entities);
}
else {
return CourseObjectFulfillment::create(array(
'coid' => $this
->id(),
'uid' => $account
->id(),
'object_type' => $this
->get('object_type')
->getString(),
));
}
}