https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34713 Bug ID: 34713 Summary: Standardize plugin hooks Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: In Discussion Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: pedro.amorim@ptfs-europe.com QA Contact: testopia@bugs.koha-community.org CC: jonathan.druart+koha@gmail.com, katrin.fischer@bsz-bw.de, m.de.rooy@rijksmuseum.nl, martin.renvoize@ptfs-europe.com, nick@bywatersolutions.com, oleonard@myacpl.org, tomascohen@gmail.com We should standardize the way plugin hooks are implemented and behave. Looking at: https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink Some hooks are called like: Koha::Plugins->new()->GetPlugins( { method => 'background_tasks', } ); and then the respective method invoked Others are just called like: Koha::Plugins->call('patron_barcode_transform', \$patron_id ); Some hooks return stuff (e.g. opac_detail_xslt_variables), others expect the param to be a ref and change in place without returning anything (e.g. patron_barcode_transform) --- Discussion: We already have hooks that behave like actions, and others that behave like filters. Wordpress put's it this way: - an action interrupts the code flow to do something, and then returns back to the normal flow without modifying anything; - a filter is used to modify something in a specific way so that the modification is then used by code later on. My proposal is: - Make it clear that a hook is either an action or a filter, either by name or by the way it's called - All actions should implement the same (example) Plugins->call('action_name', $args) signature - All filters should implement the same (example) Plugins->call('filter_name', $args) signature and return $args -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.