From 3b01b816f1c52e187babf1988d7e7d765fe18299 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 25 Nov 2014 13:52:27 +0100 Subject: [PATCH] CustomerVendor-Presenter: croaken, wenn Parameter fehlen oder falsch sind --- SL/Presenter/CustomerVendor.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SL/Presenter/CustomerVendor.pm b/SL/Presenter/CustomerVendor.pm index 2bf5ebc3c..4a3702970 100644 --- a/SL/Presenter/CustomerVendor.pm +++ b/SL/Presenter/CustomerVendor.pm @@ -39,7 +39,14 @@ sub _customer_vendor { sub customer_vendor_picker { my ($self, $name, $value, %params) = @_; - $value = SL::DB::Manager::Customer->find_by(id => $value) if $value && !ref $value; + croak 'Unknown "type" parameter' unless $params{type} =~ m{^(?:customer|vendor)$}; + croak 'Unknown value class' if $value && (ref($value) !~ m{^SL::DB::(?:Customer|Vendor)$}); + + if ($value && !ref $value) { + my $class = $params{type} eq 'customer' ? 'SL::DB::Manager::Customer' : 'SL::DB::Manager::Vendor'; + $value = $class->find_by(id => $value); + } + my $id = delete($params{id}) || $self->name_to_id($name); my $fat_set_item = delete $params{fat_set_item}; -- 2.20.1