Bug 30072: Add missing hold actions plugin hooks
This patch introduces the after_hold_action plugin hook, with 4
different 'action' parameters:
- fill
- cancel
- suspend
- resume
To test:
1. Apply the unit tests
2. Run:
$ kshell
k$ t/db_dependent/Koha/Plugins/Holds_hooks.t -v
=> FAIL: The hooks are not in the code, so the expected output from the
Koha::Plugin::Test plugin is not there, and the tests fail
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D
Note: I think we could deprecate 'after_hold_create' and migrate it to
the one introduced here, using the 'place' action.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit f2d1b126b9)
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
parent
c07cee37bb
commit
4dd61b0fc4
|
|
@ -1122,7 +1122,15 @@ sub ModReserveFill {
|
|||
if C4::Context->preference('HoldsLog');
|
||||
|
||||
# FIXME Must call Koha::Hold->cancel ? => No, should call ->filled and add the correct log
|
||||
Koha::Old::Hold->new( $hold->unblessed() )->store();
|
||||
my $old_hold = Koha::Old::Hold->new( $hold->unblessed() )->store();
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'fill',
|
||||
payload => { hold => $old_hold->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
$hold->delete();
|
||||
|
||||
|
|
|
|||
28
Koha/Hold.pm
28
Koha/Hold.pm
|
|
@ -36,6 +36,7 @@ use Koha::Items;
|
|||
use Koha::Libraries;
|
||||
use Koha::Old::Holds;
|
||||
use Koha::Calendar;
|
||||
use Koha::Plugins;
|
||||
|
||||
use Koha::Exceptions::Hold;
|
||||
|
||||
|
|
@ -114,6 +115,14 @@ sub suspend_hold {
|
|||
$self->suspend_until($date);
|
||||
$self->store();
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'suspend',
|
||||
payload => { hold => $self->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, Dumper( $self->unblessed ) )
|
||||
if C4::Context->preference('HoldsLog');
|
||||
|
||||
|
|
@ -134,6 +143,14 @@ sub resume {
|
|||
|
||||
$self->store();
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'resume',
|
||||
payload => { hold => $self->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
logaction( 'HOLDS', 'RESUME', $self->reserve_id, Dumper($self->unblessed) )
|
||||
if C4::Context->preference('HoldsLog');
|
||||
|
||||
|
|
@ -547,7 +564,16 @@ sub cancel {
|
|||
}
|
||||
}
|
||||
|
||||
$self->_move_to_old;
|
||||
my $old_me = $self->_move_to_old;
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'cancel',
|
||||
payload => { hold => $old_me->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
$self->SUPER::delete(); # Do not add a DELETE log
|
||||
|
||||
# now fix the priority on the others....
|
||||
|
|
|
|||
Loading…
Reference in New Issue