From c55a010e8a39e94b0e210f497304bd158f06000a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 11 Mar 2022 11:37:10 -0300 Subject: [PATCH] Bug 19532: (QA follow-up) Better relationship names This patch makes the relationship names be ready for future API developments for recalls, by making their names match the method names. To test: 1. Apply this patch 2. Run the tests => SUCCESS: No change 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- Koha/Biblio.pm | 2 +- Koha/Recall.pm | 18 +++++++++++------- Koha/Schema/Result/Recall.pm | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 42984a04e3..8379f207d6 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1164,7 +1164,7 @@ sub get_marc_host { =head3 recalls - my @recalls = $biblio->recalls; + my $recalls = $biblio->recalls; Return all active recalls attached to this biblio, sorted by oldest first diff --git a/Koha/Recall.pm b/Koha/Recall.pm index 0ea8c1c36d..682d8805f4 100644 --- a/Koha/Recall.pm +++ b/Koha/Recall.pm @@ -21,9 +21,10 @@ use Modern::Perl; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); -use Koha::Patron; -use Koha::Biblio; -use Koha::Item; +use Koha::Biblios; +use Koha::Items; +use Koha::Libraries; +use Koha::Patrons; use base qw(Koha::Object); @@ -33,7 +34,7 @@ Koha::Recall - Koha Recall Object class =head1 API -=head2 Internal methods +=head2 Class methods =cut @@ -77,7 +78,7 @@ Returns the related Koha::Patron object for this recall. sub patron { my ( $self ) = @_; - my $patron_rs = $self->_result->borrower; + my $patron_rs = $self->_result->patron; return unless $patron_rs; return Koha::Patron->_new_from_dbic( $patron_rs ); } @@ -92,8 +93,9 @@ Returns the related Koha::Library object for this recall. sub library { my ( $self ) = @_; - $self->{_library} = Koha::Libraries->find( $self->branchcode ); - return $self->{_library}; + my $library_rs = $self->_result->library; + return unless $library_rs; + return Koha::Library->_new_from_dbic( $library_rs ); } =head3 checkout @@ -465,6 +467,8 @@ sub set_finished { return $self; } +=head2 Internal methods + =head3 _type =cut diff --git a/Koha/Schema/Result/Recall.pm b/Koha/Schema/Result/Recall.pm index 3918157da2..c3c63d9f9e 100644 --- a/Koha/Schema/Result/Recall.pm +++ b/Koha/Schema/Result/Recall.pm @@ -293,14 +293,14 @@ __PACKAGE__->belongs_to( ); __PACKAGE__->belongs_to( - "borrower", + "patron", "Koha::Schema::Result::Borrower", { borrowernumber => "borrowernumber" }, { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); __PACKAGE__->belongs_to( - "branch", + "library", "Koha::Schema::Result::Branch", { branchcode => "branchcode" }, { -- 2.35.1