From ce34d88099c72821bd9033130aa09fc0c3d7302a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 22 Feb 2018 11:19:50 -0300 Subject: [PATCH] Bug 20287: Koha::Object->get_from_storage May be part of a separate bug report if needed TODO - add POD + tests Signed-off-by: Josef Moravec Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 1144ee4b819e01ebad890f562d2754cda8d4e3ad) (rmaint comment - backported get_from_storage as it's required by new tests added to bug 21385 - Correctly count all items in basket for booksellers list) Signed-off-by: Martin Renvoize --- Koha/Object.pm | 11 +++++++++++ Koha/Schema/Result/Borrower.pm | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Koha/Object.pm b/Koha/Object.pm index e35ff0b85e..e62af3eb11 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -219,6 +219,17 @@ sub unblessed { return { $self->_result->get_columns }; } +=head3 $object->get_from_storage; + +=cut + +sub get_from_storage { + my ( $self, $attrs ) = @_; + my $stored_object = $self->_result->get_from_storage($attrs); + my $object_class = Koha::Object::_get_object_class( $self->_result->result_class ); + return $object_class->_new_from_dbic($stored_object); +} + =head3 $object->TO_JSON Returns an unblessed representation of the object, suitable for JSON output. diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index b739284068..68f7da6a22 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -1418,5 +1418,8 @@ __PACKAGE__->add_columns( sub koha_objects_class { 'Koha::Patrons'; } +sub koha_object_class { + 'Koha::Patron'; +} 1; -- 2.39.5