Manager-Modul für Employee-Model mit Funktion 'current', die die aktuelle Angestellte...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 30 Dec 2010 14:45:41 +0000 (15:45 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 30 Dec 2010 14:45:41 +0000 (15:45 +0100)
SL/DB/Employee.pm
SL/DB/Manager/Employee.pm [new file with mode: 0644]

index 841696b..1ef565e 100644 (file)
@@ -1,13 +1,9 @@
-# This file has been auto-generated only because it didn't exist.
-# Feel free to modify it at will; it will not be overwritten automatically.
-
 package SL::DB::Employee;
 
 use strict;
 
 use SL::DB::MetaSetup::Employee;
+use SL::DB::Manager::Employee;
 
-# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
-__PACKAGE__->meta->make_manager_class;
 
 1;
diff --git a/SL/DB/Manager/Employee.pm b/SL/DB/Manager/Employee.pm
new file mode 100644 (file)
index 0000000..e52eebb
--- /dev/null
@@ -0,0 +1,17 @@
+package SL::DB::Manager::Employee;
+
+use strict;
+
+use SL::DB::Helpers::Manager;
+use base qw(SL::DB::Helpers::Manager);
+
+sub object_class { 'SL::DB::Employee' }
+
+__PACKAGE__->make_manager_methods;
+
+sub current {
+  return undef unless $::form && $::form->{login};
+  return shift->find_by(login => $::form->{login});
+}
+
+1;