Revision 3be85e17
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
SL/DB/BackgroundJob.pm | ||
---|---|---|
11 | 11 |
use SL::DB::BackgroundJobHistory; |
12 | 12 |
|
13 | 13 |
use SL::BackgroundJob::Test; |
14 |
use SL::System::Process; |
|
14 | 15 |
|
15 | 16 |
sub update_next_run_at { |
16 | 17 |
my $self = shift; |
... | ... | |
67 | 68 |
return {}; |
68 | 69 |
} |
69 | 70 |
|
71 |
sub validate { |
|
72 |
my ($self) = @_; |
|
73 |
|
|
74 |
my @errors; |
|
75 |
|
|
76 |
push @errors, $::locale->text('The execution type is invalid.') if ($self->type || '') !~ m/^(?: once | interval )$/x; |
|
77 |
|
|
78 |
if ( (($self->package_name || '') !~ m/^ [A-Z][A-Za-z0-9]+ $/x) |
|
79 |
|| ! -f (SL::System::Process::exe_dir() . "/SL/BackgroundJob/" . $self->package_name . ".pm")) { |
|
80 |
push @errors, $::locale->text('The package name is invalid.'); |
|
81 |
} |
|
82 |
|
|
83 |
eval { |
|
84 |
DateTime::Event::Cron->new_from_cron($self->cron_spec)->next(DateTime->now_local); |
|
85 |
1; |
|
86 |
} or push @errors, $::locale->text('The execution schedule is invalid.'); |
|
87 |
|
|
88 |
return @errors; |
|
89 |
} |
|
90 |
|
|
70 | 91 |
1; |
Auch abrufbar als: Unified diff
Validierungsfunktion für BackgroundJobs