From: Moritz Bunkus Date: Wed, 20 Dec 2017 14:29:09 +0000 (+0100) Subject: Presenter: richtige Presenter-Klasse bei DB-Klassen Customer/Vendor laden X-Git-Tag: release-3.5.4~552 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=842a2e4c7680cb09fae1522839502288df23b1c9;p=kivitendo-erp.git Presenter: richtige Presenter-Klasse bei DB-Klassen Customer/Vendor laden --- diff --git a/SL/DB/Object.pm b/SL/DB/Object.pm index c258761d1..52e9ec930 100755 --- a/SL/DB/Object.pm +++ b/SL/DB/Object.pm @@ -22,6 +22,11 @@ my @rose_reserved_methods = qw( not_found save update import ); +my %db_to_presenter_mapping = ( + Customer => 'CustomerVendor', + Vendor => 'CustomerVendor', +); + sub new { my $class = shift; my $self = $class->SUPER::new(); @@ -240,16 +245,13 @@ sub clone_and_reset { } sub presenter { - my ($class_or_self) = @_; - - if (ref $class_or_self) { - my $class = ref $class_or_self; - $class =~ s{^SL::DB::}{SL::Presenter::}; - return SL::DB::Helper::Presenter->new($class, $class_or_self); - } else { - $class_or_self =~ s{^SL::DB::}{SL::Presenter::}; - return $class_or_self; - } + my ($self) = @_; + + my $class = ref $self; + $class =~ s{^SL::DB::}{}; + $class = "SL::Presenter::" . ($db_to_presenter_mapping{$class} // $class); + + return SL::DB::Helper::Presenter->new($class, $self); } sub as_debug_info {