You are here

public static function CourseEnrollment::create in Course 8.3

Same name and namespace in other branches
  1. 8.2 src/Entity/CourseEnrollment.php \Drupal\course\Entity\CourseEnrollment::create()

Use the Course's configured enrollment type.

Overrides EntityBase::create

4 calls to CourseEnrollment::create()
Course::enroll in src/Entity/Course.php
Enroll a user in this course.
CourseController::renderTake in src/Controller/CourseController.php
Take a course.
CourseController::renderTake in src/Controller/CourseController.php
Take a course.
CourseEnrollmentTestCase::testCourseEnrollmentTimestamps in tests/src/Functional/CourseEnrollmentTestCase.php
Test a manual course enrollment. Ensure that created and started timestamping works as expected.

File

src/Entity/CourseEnrollment.php, line 59

Class

CourseEnrollment
Defines the profile entity class.

Namespace

Drupal\course\Entity

Code

public static function create(array $values = array()) {
  $course = Course::load($values['cid']);
  $values['type'] = $course
    ->get('enrollment_type')
    ->getString();
  return parent::create($values);
}