From 1144ee4b819e01ebad890f562d2754cda8d4e3ad 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 --- 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 8663b8654b..3381116ead 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -1433,5 +1433,8 @@ __PACKAGE__->add_columns( sub koha_objects_class { 'Koha::Patrons'; } +sub koha_object_class { + 'Koha::Patron'; +} 1; -- 2.39.5