Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Do
-
2.7
-
None
-
MOODLE_27_STABLE
Description
Event triggers can be quite lengthy. We can do a lot of refactor using proper methods here. For example in many places we have $cm, which is used to create the event. A method like:-
public static function create_from_cm($cm, $other = array()){}
|
Would simplify the trigger a lot. Such methods could be reused among various events and a trait for each of these methods would make life much easy.
Other possible methods:-
create_from_module_instance()
create_from_user()
create_from_chapter() (for books)
We are already doing this in a few events (Example books) and all the events are duplicating the methods in their definitions.