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

Allow hooks to use attributes instead of described_hook interface

XMLWordPrintable

    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • MDL-81011-main
    • Hide

      This is fairlty difficult to unit test as it relies on current data.

      1. Log in as admin
      2. Navigate to Site admin -> Development -> Hooks overview
        1. Confirm that all of the hooks have a description underneath the hook name
        2. Confirm that some of the hooks also have a tag in a coloured bubble
      Show
      This is fairlty difficult to unit test as it relies on current data. Log in as admin Navigate to Site admin -> Development -> Hooks overview Confirm that all of the hooks have a description underneath the hook name Confirm that some of the hooks also have a tag in a coloured bubble

      When writing a hook, you are encouraged to make it a described hook to add an untranslated description and set of tags.

      Really though, that information is metadata and we require a whole heap of unnecessary boilerplate just for those.

      Enter... attributes

      #[\core\attribute\label('Allows plugins to insert nodes into site primary navigation')]
      #[\core\attribute\tags('navigation')]
      class primary_extend implements \Psr\EventDispatcher\StoppableEventInterface {
          // ...
      }
      

      We can add attributes as an optional alternative to implementing the described_hook interface and it drastically reduces boilerplate.

      In time I'd like to make greater use of attributes such as these.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Paul Holden Paul Holden
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 4 hours, 44 minutes
                2d 4h 44m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.