From d91ffe400949db8ff717de3924ec1df23fa847cc Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 14 Dec 2023 14:16:01 +0000 Subject: [PATCH] Bug 35581: Koha::Illbackend -> Koha::ILL::Backend Koha/Illbackend.pm -> Koha/ILL/Backend.pm Koha/REST/V1/Illbackends.pm -> Koha/REST/V1/ILL/Backends.pm Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi Signed-off-by: Pedro Amorim --- Koha/{Illbackend.pm => ILL/Backend.pm} | 12 ++--- .../V1/{Illbackends.pm => ILL/Backends.pm} | 48 +++++++++---------- api/v1/swagger/paths/ill_backends.yaml | 8 ++-- .../Koha/{Illbackend.t => ILL/Backend.t} | 6 +-- 4 files changed, 37 insertions(+), 37 deletions(-) rename Koha/{Illbackend.pm => ILL/Backend.pm} (95%) rename Koha/REST/V1/{Illbackends.pm => ILL/Backends.pm} (60%) rename t/db_dependent/Koha/{Illbackend.t => ILL/Backend.t} (97%) diff --git a/Koha/Illbackend.pm b/Koha/ILL/Backend.pm similarity index 95% rename from Koha/Illbackend.pm rename to Koha/ILL/Backend.pm index 5be0c6efd72..1c712320506 100644 --- a/Koha/Illbackend.pm +++ b/Koha/ILL/Backend.pm @@ -1,4 +1,4 @@ -package Koha::Illbackend; +package Koha::ILL::Backend; # Copyright PTFS Europe 2023 # @@ -23,19 +23,19 @@ use base qw(Koha::Object); =head1 NAME -Koha::Illbackend - Koha Illbackend Object class +Koha::ILL::Backend - Koha Illbackend Object class =head2 Class methods =head3 new -New illbackend +New ILL Backend =cut sub new { my $class = shift; - my $self = {}; + my $self = {}; return bless $self, $class; } @@ -119,7 +119,7 @@ sub embed { foreach my $embed_req ( split /\s*,\s*/, $embed_header ) { if ( $embed_req eq 'statuses+strings' ) { - $return_embed->{statuses} = $self->existing_statuses( $backend_id ); + $return_embed->{statuses} = $self->existing_statuses($backend_id); } } return $return_embed; @@ -129,7 +129,7 @@ sub embed { =head3 _type - my $type = Koha::Illbackend->_type; + my $type = Koha::ILL::Backend->_type; Return this object's type diff --git a/Koha/REST/V1/Illbackends.pm b/Koha/REST/V1/ILL/Backends.pm similarity index 60% rename from Koha/REST/V1/Illbackends.pm rename to Koha/REST/V1/ILL/Backends.pm index 45b9c29922d..58eec04a2cc 100644 --- a/Koha/REST/V1/Illbackends.pm +++ b/Koha/REST/V1/ILL/Backends.pm @@ -1,19 +1,19 @@ -package Koha::REST::V1::Illbackends; +package Koha::REST::V1::ILL::Backends; # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; @@ -21,11 +21,11 @@ use Mojo::Base 'Mojolicious::Controller'; use Koha::Illrequest::Config; use Koha::Illrequests; -use Koha::Illbackend; +use Koha::ILL::Backend; =head1 NAME -Koha::REST::V1::Illbackends +Koha::REST::V1::ILL::Backends =head2 Operations @@ -38,9 +38,9 @@ Return a list of available ILL backends and its capabilities sub list { my $c = shift->openapi->valid_input; - my $config = Koha::Illrequest::Config->new; - my $backends = $config->available_backends; - my $backend_module = Koha::Illbackend->new; + my $config = Koha::ILL::Request::Config->new; + my $backends = $config->available_backends; + my $backend_module = Koha::ILL::Backend->new; my @data; foreach my $b (@$backends) { @@ -73,18 +73,19 @@ sub get { return try { - #FIXME: Should we move load_backend into Koha::Illbackend... + #FIXME: Should we move load_backend into Koha::ILL::Backend... # or maybe make Koha::Ill::Backend a base class for all # backends? my $backend = Koha::Illrequest->new->load_backend($backend_id); - my $backend_module = Koha::Illbackend->new; + my $backend_module = Koha::ILL::Backend->new; - my $embed = - $backend_module->embed( $backend_id, - $c->req->headers->header('x-koha-embed') ); + my $embed = $backend_module->embed( + $backend_id, + $c->req->headers->header('x-koha-embed') + ); - #TODO: We need a to_api method in Koha::Illbackend + #TODO: We need a to_api method in Koha::ILL::Backend my $return = { ill_backend_id => $backend_id, capabilities => $backend->capabilities, @@ -94,8 +95,7 @@ sub get { status => 200, openapi => $embed ? { %$return, %$embed } : $return, ); - } - catch { + } catch { return $c->render( status => 404, openapi => { error => "ILL backend does not exist" } diff --git a/api/v1/swagger/paths/ill_backends.yaml b/api/v1/swagger/paths/ill_backends.yaml index f076137527b..52ff93dcb62 100644 --- a/api/v1/swagger/paths/ill_backends.yaml +++ b/api/v1/swagger/paths/ill_backends.yaml @@ -1,8 +1,8 @@ --- /ill/backends: get: - x-mojo-to: Illbackends#list - operationId: listIllbackends + x-mojo-to: ILL::Backends#list + operationId: listIllBackends tags: - ill_backends summary: List ILL backends @@ -52,8 +52,8 @@ ill: "1" "/ill/backends/{ill_backend_id}": get: - x-mojo-to: Illbackends#get - operationId: getIllbackends + x-mojo-to: ILL::Backends#get + operationId: getIllBackends tags: - ill_backends summary: Get ILL backend diff --git a/t/db_dependent/Koha/Illbackend.t b/t/db_dependent/Koha/ILL/Backend.t similarity index 97% rename from t/db_dependent/Koha/Illbackend.t rename to t/db_dependent/Koha/ILL/Backend.t index 43b0bc5fe68..8a59e16e059 100755 --- a/t/db_dependent/Koha/Illbackend.t +++ b/t/db_dependent/Koha/ILL/Backend.t @@ -21,7 +21,7 @@ use Modern::Perl; use Test::More tests => 1; -use Koha::Illbackend; +use Koha::ILL::Backend; use t::lib::TestBuilder; use t::lib::Mocks; @@ -36,7 +36,7 @@ subtest 'existing_statuses() tests' => sub { $schema->storage->txn_begin; Koha::Illrequests->search->delete; - # Mock ILLBackend (as object) + # Mock external ILLBackend (as object) my $backend = Test::MockObject->new; $backend->set_isa('Koha::Illbackends::Mock'); $backend->set_always( 'name', 'Mock' ); @@ -133,7 +133,7 @@ subtest 'existing_statuses() tests' => sub { } ); - my $backend_module = Koha::Illbackend->new; + my $backend_module = Koha::ILL::Backend->new; my $existing_statuses = $backend_module->existing_statuses('Mock'); -- 2.30.2