protected function ImportTrainingForm::importCourse in Opigno module 8
Same name and namespace in other branches
- 3.x src/Form/ImportTrainingForm.php \Drupal\opigno_module\Form\ImportTrainingForm::importCourse()
Create Course entity.
Parameters
array $course_content: List of settings from imported file.
Return value
Throws
\Exception
1 call to ImportTrainingForm::importCourse()
- ImportTrainingForm::submitForm in src/
Form/ ImportTrainingForm.php - Form submission handler.
File
- src/
Form/ ImportTrainingForm.php, line 519
Class
- ImportTrainingForm
- Import Course form.
Namespace
Drupal\opigno_module\FormCode
protected function importCourse($course_content) {
$course = $this
->buildEntityOptions($course_content, 'opigno_course');
$new_course = Group::create($course);
if (!empty($course_content['field_course_description'][0])) {
$new_course->field_course_description->format = $course_content['field_course_description'][0]['format'];
}
$new_course
->save();
return $new_course;
}