Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-45217

Create traits for refactoring event triggers

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Do
    • 2.7
    • None
    • Events API

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ankit_frenz Ankit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: