Bugzilla – Attachment 182294 Details for
Bug 39870
Add plugin hook for making arbitrary data available to notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39870: Add `notices_content()` plugin hook
Bug-39870-Add-noticescontent-plugin-hook.patch (text/plain), 2.22 KB, created by
David Nind
on 2025-05-12 14:39:52 UTC
(
hide
)
Description:
Bug 39870: Add `notices_content()` plugin hook
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-05-12 14:39:52 UTC
Size:
2.22 KB
patch
obsolete
>From 38f9031eee79c25b390566c06be5d37918314bf6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 9 May 2025 17:10:49 -0300 >Subject: [PATCH] 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> >--- > C4/Letters.pm | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 9a4a0ee104..b7c6b0cedd 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -623,6 +623,30 @@ sub GetPreparedLetter { > $objects->{librarian} = Koha::Patrons->find( C4::Context->userenv->{number} ) if ($userenv); > } > >+ # add plugin-generated objects >+ if ( C4::Context->config("enable_plugins") ) { >+ my @plugins = Koha::Plugins->new->GetPlugins( >+ { >+ method => 'notices_content', >+ } >+ ); >+ >+ if (@plugins) { >+ foreach my $plugin (@plugins) { >+ my $namespace = $plugin->get_metadata()->{namespace}; >+ if ($namespace) { >+ try { >+ if ( my $content = $plugin->notices_content( \%params ) ) { >+ $objects->{plugin_content}->{$namespace} = $content; >+ } >+ } catch { >+ next; >+ }; >+ } >+ } >+ } >+ } >+ > # Best guess at language 'default' notice is written for include handling > if ( $lang eq 'default' ) { > >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39870
:
182265
|
182266
|
182293
|
182294
|
182418
|
182419