MDL-39883 events: Create a new api create_from_cm for module create event

This commit is contained in:
Ankit Agarwal
2014-06-18 15:39:02 +08:00
parent 0a3d81c261
commit e20d306969
3 changed files with 35 additions and 20 deletions
+5 -10
View File
@@ -148,16 +148,11 @@ function add_moduleinfo($moduleinfo, $course, $mform = null) {
$sectionid = course_add_cm_to_section($course, $moduleinfo->coursemodule, $moduleinfo->section);
// Trigger event based on the action we did.
$event = \core\event\course_module_created::create(array(
'courseid' => $course->id,
'context' => $modcontext,
'objectid' => $moduleinfo->coursemodule,
'other' => array(
'modulename' => $moduleinfo->modulename,
'name' => $moduleinfo->name,
'instanceid' => $moduleinfo->instance
)
));
// Api create_from_cm expects modname and id property, and we don't want to modify $moduleinfo since we are returning it.
$eventdata = clone $moduleinfo;
$eventdata->modname = $eventdata->modulename;
$eventdata->id = $eventdata->coursemodule;
$event = \core\event\course_module_created::create_from_cm($eventdata, $modcontext);
$event->trigger();
$moduleinfo = edit_module_post_actions($moduleinfo, $course);