public static final function create_from_cm($cm, $modcontext = null) {
        // If not set, get the module context.
        if (empty($modcontext)) {
            $modcontext = \context_module::instance($cm->id);
        }

        // Create event object for course module update action.
        $event = static::create(array(
            'context'  => $modcontext,
            'objectid' => $cm->id,
            'other'    => array(
                'modulename' => $cm->modname,
                'instanceid' => $cm->instance,
                'name'       => $cm->name,
            )
        ));
        return $event;
    }
public static final function create_from_cm($cm, $modcontext = null) {
        // If not set, get the module context.
        if (empty($modcontext)) {
            $modcontext = \context_module::instance($cm->id);
        }

        // Create event object for course module update action.
        $event = static::create(array(
            'context'  => $modcontext,
            'objectid' => $cm->id,
            'other'    => array(
                'modulename' => $cm->modname,
                'instanceid' => $cm->instance,
                'name'       => $cm->name,
            )
        ));
        return $event;
    }
public static final function create_from_cm ( $ cm , $ modcontext = null ) { // If not set, get the module context. if ( empty ( $ modcontext ) ) { $ modcontext = \ context_module :: instance ( $ cm -> id ) ; } // Create event object for course module update action. $ event = static :: create ( array ( 'context' => $ modcontext , 'objectid' => $ cm -> id , 'other' => array ( 'modulename' => $ cm -> modname , 'instanceid' => $ cm -> instance , 'name' => $ cm -> name , ) ) ) ; return $ event ; }
Set data to create new event from course module.

@param \cm_info|\stdClass $cm course module instance, as returned by {@link get_coursemodule_from_id}
or {@link get_coursemodule_from_instance}.
@param \context_module $modcontext module context instance
@return \core\event\base returns instance of new event
Set data to create new event from course module .