]> git.koha-community.org Git - koha.git/commit
Bug 25044: Remove the need to define koha_object[s]_class for standard object class...
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 2 Apr 2020 14:03:17 +0000 (16:03 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 14 Apr 2020 07:35:53 +0000 (08:35 +0100)
commit65c5407d41fd5ba8a37f163b1a02e9c5a8cfa9f8
tree468401553cdcab33494adbec1d58839b6caa57cc
parent81c141d41aef41d2dbdd50b1874f4964b83d6767
Bug 25044: Remove the need to define koha_object[s]_class for standard object class names

In Koha::Object[s]->prefetch_whitelist, there is a call to the koha_object[s]_class DBIC resultset class. We should not, otherwise those 2 methods will have to be defined all the time, even when we can guess it easily.

Koha::Item <> Schema::Result::Item => standard
Koha::Acquisition::Order <> Schema::Result::Aqorder => non-standard

sub _get_object_class {
    my ( $type ) = @_;
    return unless $type;

    if( $type->can('koha_object_class') ) {
        return $type->koha_object_class;
    }
    $type =~ s|Schema::Result::||;
    return ${type};
}

Test plan:
 % prove t/db_dependent/Koha/Object.t t/db_dependent/Koha/Objects.t
should return green before and after this patch

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Object.pm
t/db_dependent/Koha/Object.t
t/db_dependent/Koha/Objects.t