From e75697253b961ad420fbf10e2fcf254c857caf4f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Sat, 9 Mar 2024 09:47:45 -0300 Subject: [PATCH] Bug 19605: Rename method and use the instantiated plugin in the call This patch makes the backend instantiation happen through a plugin object method instead of a static one. This way, the (already) instantiated plugin can be reused (if needed) in the plugin workflow like this: sub new_il_backend { my ($self, $params) = @_; return Custom::Backend->new( { config => $params->{config}, logger => $params->{logger}, plugin => $self, } ); } The passed plugin object would then be used to retrieve whatever plugin-defined configurations, template paths or even helper methods. On INN-Reach, it gives the backend access to API user agents, task queue injection, etc. This patch also renames the method so it is more straight-forward this is related to ILL. Signed-off-by: Tomas Cohen Arazi --- Koha/Illrequest.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 600cfe53b5e..7527d239696 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -435,13 +435,11 @@ sub load_backend { "An invalid backend ID was requested ('')"); } + # Find plugin implementing the backend for the request my $backend_plugin = $self->get_backend_plugin($backend_name); if ($backend_plugin) { - # New way of loading backends: Through plugins - my $backend_plugin_class = $backend_plugin->{class}; - - $self->{_my_backend} = $backend_plugin_class->new_backend( + $self->{_my_backend} = $backend_plugin->new_ill_backend( { config => $self->_config, logger => Koha::Illrequest::Logger->new @@ -449,7 +447,7 @@ sub load_backend { ); } elsif ($backend_name) { - # Old way of loading backends: Through backend_dir config + # Fallback to loading through backend_dir config my @raw = qw/Koha Illbackends/; # Base Path my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name -- 2.44.0