Summary: | Add plugin hook for making arbitrary data available to notices | ||
---|---|---|---|
Product: | Koha | Reporter: | Lisette Scheer <lisette> |
Component: | Plugin architecture | Assignee: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Status: | Pushed to main --- | QA Contact: | Lisette Scheer <lisette> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | michaela.sieber, tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
GIT URL: | Change sponsored?: | --- | |
Patch complexity: | Small patch | Documentation contact: | |
Documentation submission: | Text to go in the release notes: |
This development allows plugins to make arbitrary data available to notices.
Each plugin has a defined namespace (e.g. 'innreach'). If a plugin implements the `notices_content` method, it will be called. The generated data structure it returns will be available to the notice author as `[% plugin_content.innreach %]`.
The hook will be passed the notice generation context, so authors can return different information based on what they need for each letter, for example.
|
|
Version(s) released in: |
25.05.00
|
Circulation function: | |
Bug Depends on: | |||
Bug Blocks: | 40037 | ||
Attachments: |
Bug 39870: Unit tests
Bug 39870: Add `notices_content()` plugin hook Bug 39870: Unit tests Bug 39870: Add `notices_content()` plugin hook Bug 39870: Unit tests Bug 39870: Add `notices_content()` plugin hook |
Description
Lisette Scheer
2025-05-09 14:31:06 UTC
Created attachment 182265 [details] [review] Bug 39870: Unit tests Created attachment 182266 [details] [review] Bug 39870: Add `notices_content()` plugin hook This patch adds a hook for adding information to notices context from plugins. The method is passed all the `GetPreparedLetter()` paramerters so it gets all the context for calculating the values to pass the template. The main target use for this hook is ILL, where we need to identify candidate ILL requests related to the filled hold for printing the right ILL-related message. The implementation is generic so it can be used for any other use case. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Plugins/Notices_content_hook.t => FAIL: The hook is not implemented, the letter doesn't include plugin-calculated data the tests expect. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Created attachment 182293 [details] [review] Bug 39870: Unit tests Signed-off-by: David Nind <david@davidnind.com> Created attachment 182294 [details] [review] Bug 39870: Add `notices_content()` plugin hook This patch adds a hook for adding information to notices context from plugins. The method is passed all the `GetPreparedLetter()` paramerters so it gets all the context for calculating the values to pass the template. The main target use for this hook is ILL, where we need to identify candidate ILL requests related to the filled hold for printing the right ILL-related message. The implementation is generic so it can be used for any other use case. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Plugins/Notices_content_hook.t => FAIL: The hook is not implemented, the letter doesn't include plugin-calculated data the tests expect. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Created attachment 182418 [details] [review] Bug 39870: Unit tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> Created attachment 182419 [details] [review] Bug 39870: Add `notices_content()` plugin hook This patch adds a hook for adding information to notices context from plugins. The method is passed all the `GetPreparedLetter()` paramerters so it gets all the context for calculating the values to pass the template. The main target use for this hook is ILL, where we need to identify candidate ILL requests related to the filled hold for printing the right ILL-related message. The implementation is generic so it can be used for any other use case. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Plugins/Notices_content_hook.t => FAIL: The hook is not implemented, the letter doesn't include plugin-calculated data the tests expect. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> Worked great and this will be great for passing ILL information to notices from plugins. Please update https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks! Pushed for 25.05! Well done everyone, thank you! I added a line under Implemented hooks on the wiki page https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks Please review if everything is correct. Thanks! We still need release notes! Thank you both. (In reply to Katrin Fischer from comment #11) > Thanks! We still need release notes! And this should go to the manual I guess. |