From 772d3fff7abf66e37bd59d4a7f2f51608fe4ff88 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 24 Jan 2025 11:26:51 +0000 Subject: [PATCH] Bug 39488: Add $result to Koha::Objects `object_class` calls This allows us to do dynamic polymorphic classing on calls to 'find', 'find_or_create', 'single', 'next', 'last' and 'as_list' etc. Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall --- Koha/Objects.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 405e6a76679..21b16d020bf 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -94,7 +94,7 @@ sub find { unless ( !@pars || none { defined($_) } @pars ) { my $result = $self->_resultset()->find(@pars); if ($result) { - $object = $self->object_class()->_new_from_dbic($result); + $object = $self->object_class($result)->_new_from_dbic($result); } } @@ -114,7 +114,7 @@ sub find_or_create { return unless $result; - my $object = $self->object_class->_new_from_dbic($result); + my $object = $self->object_class($result)->_new_from_dbic($result); return $object; } @@ -301,7 +301,7 @@ sub single { my $single = $self->_resultset()->single; return unless $single; - return $self->object_class()->_new_from_dbic($single); + return $self->object_class($single)->_new_from_dbic($single); } =head3 Koha::Objects->next(); @@ -319,7 +319,7 @@ sub next { my $result = $self->_resultset()->next(); return unless $result; - my $object = $self->object_class()->_new_from_dbic($result); + my $object = $self->object_class($result)->_new_from_dbic($result); return $object; } @@ -341,7 +341,7 @@ sub last { my ($result) = $self->_resultset->slice( $count - 1, $count - 1 ); - my $object = $self->object_class()->_new_from_dbic($result); + my $object = $self->object_class($result)->_new_from_dbic($result); return $object; } @@ -507,7 +507,7 @@ wraps the DBIC object in a corresponding Koha object sub _wrap { my ( $self, @dbic_rows ) = @_; - my @objects = map { $self->object_class->_new_from_dbic($_) } @dbic_rows; + my @objects = map { $self->object_class($_)->_new_from_dbic($_) } @dbic_rows; return @objects; } -- 2.49.0