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

This commit is contained in:
Ankit Agarwal
2014-06-18 16:02:42 +08:00
parent 92ac518fdc
commit fd554631f8
3 changed files with 35 additions and 20 deletions
+5 -10
View File
@@ -145,16 +145,11 @@ function add_moduleinfo($moduleinfo, $course, $mform = null) {
}
// 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();
add_to_log($course->id, $moduleinfo->modulename, "add",