This hook will be called after a hold has been placed. The need behind that is to create a plugin that will send a mail to the patron that has borrowed the reserved item, saying something like "Someone has requested this item, please return it as soon as you can"
Created attachment 95358 [details] [review] Bug 24031: Add plugin hook after_hold_create It is called after a hold has been placed Test plan: 1. Write a plugin that implements only after_hold_create (see `perldoc Koha::Plugins` for implementation details). Install it and enable it 2. Place a hold and verify that your plugin method has been called with the right parameters
Created attachment 95657 [details] [review] Bug 24031: Add plugin hook after_hold_create It is called after a hold has been placed Test plan: 1. Write a plugin that implements only after_hold_create (see `perldoc Koha::Plugins` for implementation details). Install it and enable it 2. Place a hold and verify that your plugin method has been called with the right parameters Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 95658 [details] [review] Bug 24031: Fix warnings Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Please remember to add the new hook to the wiki once pushed: https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks
Created attachment 98788 [details] [review] Bug 24031: Add plugin hook after_hold_create It is called after a hold has been placed Test plan: 1. Write a plugin that implements only after_hold_create (see `perldoc Koha::Plugins` for implementation details). Install it and enable it 2. Place a hold and verify that your plugin method has been called with the right parameters Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi>
Created attachment 98789 [details] [review] Bug 24031: Fix warnings Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi>
if (C4::Context->preference('UseKohaPlugins') && C4::Context->config('enable_plugins')) { + my @plugins = $class->new({ enable_plugins => 1 })->GetPlugins({ method => $method }); + my @responses; + foreach my $plugin (@plugins) { + my $response = $plugin->$method(@args); + push @responses, $response; + } + + return @responses; + } No error checking? What if one of the plugins fails, should you continue? Should you use eval? Should $method be checked somehow before calling it rightaway?
No reply to earlier questions. No update for bug 20415. Changing status.
Created attachment 105256 [details] [review] Bug 24031: Remove check for syspref UseKohaPlugins UseKohaPlugins has been removed by bug 20415
Created attachment 105257 [details] [review] Bug 24031: Add safety checks in Koha::Plugins::call - Check that the plugin has the method before calling it - Call the method in an eval block to prevent fatal errors
Created attachment 105693 [details] [review] Bug 24031: Add plugin hook after_hold_create It is called after a hold has been placed Test plan: 1. Write a plugin that implements only after_hold_create (see `perldoc Koha::Plugins` for implementation details). Install it and enable it 2. Place a hold and verify that your plugin method has been called with the right parameters Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 105694 [details] [review] Bug 24031: Add plugin hook after_hold_create It is called after a hold has been placed Test plan: 1. Write a plugin that implements only after_hold_create (see `perldoc Koha::Plugins` for implementation details). Install it and enable it 2. Place a hold and verify that your plugin method has been called with the right parameters Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 105695 [details] [review] Bug 24031: Fix warnings Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 105696 [details] [review] Bug 24031: Remove check for syspref UseKohaPlugins UseKohaPlugins has been removed by bug 20415 Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 105697 [details] [review] Bug 24031: Add safety checks in Koha::Plugins::call - Check that the plugin has the method before calling it - Call the method in an eval block to prevent fatal errors Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Needs hook listed in Koha::Plugin::Test with corresponding unit tests.
Created attachment 107042 [details] [review] Bug 24031: Add hook to test plugin with unit test
Created attachment 107365 [details] [review] Bug 24031: (QA follow-up) Add tests for the AddReserve intervention This patch adds tests for AddReserve Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Julian, can you have a look at bug 26063 and tell us if it's what you had in mind with Koha::Plugins->call please?
(In reply to Jonathan Druart from comment #19) > Julian, can you have a look at bug 26063 and tell us if it's what you had in > mind with Koha::Plugins->call please? This is exactly what I had in mind :)
Pushed to master for 20.11, thanks to everybody involved!
enhancement not backported to 20.05.x series