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

Create traits for refactoring event triggers

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.7
    • Fix Version/s: BACKEND
    • Component/s: Events API
    • Labels:

      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

            Assignee:
            Unassigned
            Reporter:
            ankit_frenz Ankit Agarwal
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: