Bugzilla – Attachment 116007 Details for
Bug 27066
Implement hooks for patrons updates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27066: Add plugin hook after_patron_action
Bug-27066-Add-plugin-hook-afterpatronaction.patch (text/plain), 2.16 KB, created by
Maryse Simard
on 2021-01-29 06:32:32 UTC
(
hide
)
Description:
Bug 27066: Add plugin hook after_patron_action
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2021-01-29 06:32:32 UTC
Size:
2.16 KB
patch
obsolete
>From 120efa99b08fded13e76e59b629e0eb86dabae3f Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >Date: Fri, 29 Jan 2021 01:09:31 -0500 >Subject: [PATCH] Bug 27066: Add plugin hook after_patron_action > >The hook is called after patron manipulations. The value of the >'action' parameter can be 'create', 'modify' or 'delete'. > >To test: >1. Write a simple plugin that implements at least the new > after_patron_action hook. >2. Install the plugin and enable it. >3. Create, modify or delete a patron and verify that the plugin method > for the hook has been called with the right parameters. >--- > Koha/Patron.pm | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 6ea9e5aae7..fbbb3de80f 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -268,6 +268,8 @@ sub store { > > logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) > if C4::Context->preference("BorrowersLog"); >+ >+ $self->get_from_storage->_after_patron_action_hooks({ action => 'create' }); > } > else { #ModMember > >@@ -341,6 +343,8 @@ sub store { > > # Final store > $self = $self->SUPER::store; >+ >+ $self->get_from_storage->_after_patron_action_hooks({ action => 'modify' }); > } > } > ); >@@ -395,6 +399,8 @@ sub delete { > $self->SUPER::delete; > > logaction( "MEMBERS", "DELETE", $self->borrowernumber, "" ) if C4::Context->preference("BorrowersLog"); >+ >+ $self->_after_patron_action_hooks({ action => 'delete' }); > } > ); > return $self; >@@ -1787,6 +1793,27 @@ sub to_api_mapping { > > =head2 Internal methods > >+=head3 _after_patron_action_hooks >+ >+Helper method that takes care of calling all plugin hooks >+ >+=cut >+ >+sub _after_patron_action_hooks { >+ my ( $self, $params ) = @_; >+ >+ my $action = $params->{action}; >+ >+ Koha::Plugins->call( >+ 'after_patron_action', >+ { >+ action => $action, >+ patron => $self, >+ patron_id => $self->borrowernumber, >+ } >+ ); >+} >+ > =head3 _type > > =cut >-- >2.17.1
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 27066
:
116007
|
116008
|
117867
|
117868