MDL-39883 events: Create a new api create_from_cm for module create event
This commit is contained in:
+5
-10
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user