https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Bug ID: 19306 Summary: Adding hooks to the plugin system Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: stefan.berndtsson@ub.gu.se QA Contact: testopia@bugs.koha-community.org We've been working on adding hook functionality to the existing plugin system. This is very much proof-of-concept code at the moment, but here is how it works. 1. Somewhere in the code you add a hook-call with a name for that hook, and pass in some data relevant to that hook. 2. Each plugin with a method matching the hook name is called in sequence, with the data as input and returning data of similar form, which is then passed on to the next matching plugin. 3. The end result is returned back from the hook-call, is put back in place, and code execution is resumed. The PoC code adds a Koha::Plugins::Handler->run_matching() method that looks up the relevant loaded plugins (using GetPlugins) and calls Koha::Plugins::Handler->run() on each of them. If plugins are not enabled, or if there is no plugin matching the hook, the input data is returned back, resulting in unaffected operation. One hook is added in Koha::SearchEngine::Elasticsearch::QueryBuilder.pm, in build_query_compat with the name "build_query_before", which is simply run before the query parsing takes place. A very simple example plugin is available at: https://github.com/ub-digit/koha-plugin-build-query-example/releases This plugin edits a query beginning with "Provider:" to do "publisher:" instead. A simple example that when using Elasticsearch makes publisher links in the bibliographic detail view clickable. The current XSLT uses the Zebra based links, that result in an unusable search. This is not meant to be the solution to the Zebra/Elasticsearch conflict in the XSLT, but it's a simple demonstration of the hook feature. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.