-
Improvement
-
Resolution: Done
-
Minor
-
None
-
4.3
-
None
-
MOODLE_403_STABLE
Since 13 February 2024, the following conventions will apply to PSR-14 hooks for Moodle.
Naming convention
- Hook names will be prefixed where necessary.
- Using prefixes for hook names will require readable forms, such as before or after.
Location
- Hook classes will be placed within the classes/hook folder of their respective component (plugin or subsystem).
Translation
- Hook descriptions will be in English and not translated via language strings.
As we are about to embark of the migration of all the older style callbacks into the new PSR-14 hooks we have an opportunity to cleanup and make more consistent all the hooks. There are already been a few questions in various different trackers for specific hooks but I think its worth coming up with a policy around current and future new hooks.
Some of these if we are going to change we should change them right now before 4.3 gets released if we have to tweak the method signatures.
Specifically:
1) Prefixes or suffixes for hook names, eg pre_myhook vs myhook_pre
2) The use of 'pre' & 'post' vs 'before' and 'after'
3) The location of hook classes, ie
lib/classes/hook/course/delete.php
lib/classes/hook/course_delete.php
course/classes/hook/delete.php
4) Should hooks be translated
Side note the tracker should have a component like 'Hooks'