SL::DB::CustomVariable::value an Customer angepasst
authorThomas Heck <theck@linet-services.de>
Mon, 24 Jun 2013 08:33:08 +0000 (10:33 +0200)
committerThomas Heck <theck@linet-services.de>
Tue, 16 Jul 2013 12:23:52 +0000 (14:23 +0200)
als getter gibt die Methode ein SL::DB::Customer-Objekt zurück.
als setter wird eine Customer-ID erwartet.

SL/DB/CustomVariable.pm

index 83ee89d..dd68cab 100644 (file)
@@ -7,6 +7,7 @@ use strict;
 
 use SL::DB::MetaSetup::CustomVariable;
 use SL::DB::CustomVariableValidity;
+use SL::DB::Customer;
 
 __PACKAGE__->meta->initialize;
 
@@ -20,6 +21,15 @@ sub value {
   goto &bool_value      if $type eq 'boolean';
   goto &timestamp_value if $type eq 'timestamp';
   goto &number_value    if $type eq 'number';
+  if ( $type eq 'customer' ) {
+    if ( defined($_[1]) ) {
+      goto &number_value;
+    }
+    else {
+      my $id = int($self->number_value);
+      return $id ? SL::DB::Customer->new(id => $id)->load() : 0;
+    }
+  }
   goto &text_value; # text and select
 }