From e06cd47e251637393d94a1f5bade48950396c87d 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 Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- Koha/Illrequest.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index db821af6df..3a1e2f08e2 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -436,13 +436,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 @@ -450,7 +448,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.39.5