From 9eedad923ae873c2bab451e2a8d7d357273d3d1c 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 | 45 ++++++++++++++++++++++---------------- Koha/ILL/Request/Config.pm | 2 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 3816271f0e6..199e0e67e37 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -25,23 +25,25 @@ 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::AdditionalContents; +use Koha::Patron; use C4::Circulation qw( CanBookBeIssued AddIssue ); @@ -435,16 +437,21 @@ sub load_backend { "An invalid backend ID was requested ('')"); } + my $backend_params = { + config => $self->_config, + logger => Koha::ILL::Request::Logger->new + }; + # Find plugin implementing the backend for the request my $backend_plugin = $self->get_backend_plugin($backend_name); - if ($backend_plugin) { - $self->{_my_backend} = $backend_plugin->new_ill_backend( - { - config => $self->_config, - logger => Koha::ILL::Request::Logger->new - } - ); + if ( $backend_name eq 'Standard' ) { + + # Load the Standard core backend + $self->{_my_backend} = Koha::ILL::Backend::Standard->new($backend_params); + } elsif ($backend_plugin) { + + $self->{_my_backend} = $backend_plugin->new_ill_backend($backend_params); } elsif ($backend_name) { # Fallback to loading through backend_dir config @@ -452,12 +459,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; @@ -1098,6 +1100,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 111317804c2..f4e19ff95f2 100644 --- a/Koha/ILL/Request/Config.pm +++ b/Koha/ILL/Request/Config.pm @@ -147,7 +147,7 @@ sub available_backends { @backends = glob "$backend_dir/*" if ($backend_dir); @backends = map { basename($_) } @backends; - my @all_backends = ( @backends, @backend_plugins_names ); + my @all_backends = ( @backends, @backend_plugins_names, 'Standard' ); @all_backends = grep { $_ =~ /$reduce/ } @all_backends if $reduce; # Return unique list of backend names in the event that the same backend is -- 2.39.2