From 4e9070f8b565f6202321ddadcc94e16b254e5c72 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 15 Dec 2023 12:53:25 +0000 Subject: [PATCH] Bug 35570: Consider 'Standard' core backend Added File::Basename qw( dirname ) Sorted Koha:: dependencies alphabetically DRYed load_backend a bit and included 'Standard' backend check Signed-off-by: David Nind --- Koha/ILL/Request.pm | 46 ++++++++++++++++++++++---------------- Koha/ILL/Request/Config.pm | 2 +- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index f9f28ad4092..1be0436dac9 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -25,22 +25,24 @@ use DateTime; use C4::Letters; use Mojo::Util qw(deprecated); +use File::Basename qw( dirname ); +use Koha::AuthorisedValue; +use Koha::AuthorisedValues; +use Koha::Biblios; use Koha::Cache::Memory::Lite; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions::Ill; +use Koha::ILL::Backend::Standard; +use Koha::ILL::Batches; use Koha::ILL::Comments; use Koha::ILL::Request::Attributes; -use Koha::AuthorisedValue; use Koha::ILL::Request::Logger; -use Koha::Patron; -use Koha::ILL::Batches; -use Koha::AuthorisedValues; -use Koha::Biblios; -use Koha::Items; use Koha::ItemTypes; +use Koha::Items; use Koha::Libraries; +use Koha::Patron; use C4::Circulation qw( CanBookBeIssued AddIssue ); @@ -435,18 +437,24 @@ sub load_backend { "An invalid backend ID was requested ('')"); } + my $backend_params = { + config => $self->_config, + logger => Koha::ILL::Request::Logger->new + }; + my $backend_plugin = $self->get_backend_plugin($backend_name); - if ($backend_plugin) { + + if ( $backend_name eq 'Standard' ) { + + # Load the Standard core backend + $self->{_my_backend} = Koha::ILL::Backend::Standard->new($backend_params); + return $self; + } elsif ($backend_plugin) { # New way of loading backends: Through plugins my $backend_plugin_class = $backend_plugin->{class}; - $self->{_my_backend} = $backend_plugin_class->new_backend( - { - config => $self->_config, - logger => Koha::ILL::Request::Logger->new - } - ); + $self->{_my_backend} = $backend_plugin_class->new_backend($backend_params); } elsif ($backend_name) { # Old way of loading backends: Through backend_dir config @@ -454,12 +462,7 @@ sub load_backend { my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name require $location; - $self->{_my_backend} = $backend_class->new( - { - config => $self->_config, - logger => Koha::ILL::Request::Logger->new - } - ); + $self->{_my_backend} = $backend_class->new($backend_params); } return $self; @@ -1089,6 +1092,11 @@ sub expand_template { # New way of loading backends: Through plugins $backend_dir = $backend_plugin->bundle_path; $backend_tmpl = $backend_dir; + + } elsif ( $backend eq 'Standard' ) { + + # Check for core Standard backend + $backend_tmpl = dirname(__FILE__) . '/Backend'; } else { # Old way of loading backends: Through backend_dir config diff --git a/Koha/ILL/Request/Config.pm b/Koha/ILL/Request/Config.pm index 61aac9f3b84..6ea73ee1c83 100644 --- a/Koha/ILL/Request/Config.pm +++ b/Koha/ILL/Request/Config.pm @@ -151,7 +151,7 @@ sub available_backends { # Return unique list of backend names in the event that the same backend is # installed as a plugin AND as the old way through backend_dir - my @all_backends = ( @backends, @backend_plugins_names ); + my @all_backends = ( @backends, @backend_plugins_names, 'Standard' ); my @all_uniq_backends = uniq(@all_backends); return \@all_uniq_backends; -- 2.30.2