[Koha-bugs] [Bug 28026] Add a 'call_recursive' method to Koha::Plugins

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Jun 29 08:16:14 CEST 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28026

--- Comment #21 from Mark Hofstetter <koha at trust-box.at> ---
As stated before I consider the plugin system to explicit ie you have to "tell"
every function/method that there may be a plugin.

For example something I am currently working on:

Problem: Customer wants to change how patron cardnumbers are autogenerated, (a
prefix and a fixed padded length)

One could make a plugin for Koha::Patron::fixup_cardnumber 

OR, my suggestion (semi pseudo code, I hop my intentions are clear)

extend the base class(es) in this case

Koha::Object->_new_from_dbic();

if (<hooksenabled>) {
require KohaObjectHooks; # whatever
}


KohaObjectHooks

use Hook::LexWrap;
wrap 'Koha::Patron::fixup_cardnumber', post =>
   sub { my ( $self ) = @_;
        $self->cardnumber( sprintf("LB%09d",  $self->cardnumber));
   };



Hook::LexWrap hat pre/post a around hook may be implemented easily

I know this a major change, but solves a least some problems

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list