X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/89c9ff022d3f13e27ba6bda085df15707fcfb0eb..e214accccd89a9c8:/SL/DB/Helper/Manager.pm?ds=inline diff --git a/SL/DB/Helper/Manager.pm b/SL/DB/Helper/Manager.pm index 8ebc362e2..b4d66da42 100644 --- a/SL/DB/Helper/Manager.pm +++ b/SL/DB/Helper/Manager.pm @@ -18,6 +18,14 @@ sub find_by { return $class->get_all(query => [ @_ ], limit => 1)->[0]; } +sub find_by_or_create { + my $class = shift; + + my $found; + eval { $found = $class->find_by(@_); }; + return defined $found ? $found : $class->object_class->new; +} + sub get_first { shift->get_all( @_,