File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ Name : pseudocron
3
+ ---
4
+ CronJob :
5
+ minimum_increment : 60
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public function execute() {
80
80
}
81
81
82
82
$ this ->LastRun = $ now ;
83
- $ this ->NextRun = $ now + $ this ->Increment ;
83
+ $ this ->NextRun = $ now + max ( $ this ->Increment , $ this -> config ()-> minimum_increment ) ;
84
84
85
85
// Execute isn't in the business of creating jobs
86
86
if ( $ this ->ID ) $ this ->write ();
@@ -110,4 +110,16 @@ public function getCallback() {
110
110
}
111
111
return $ val ;
112
112
}
113
+
114
+ /**
115
+ * Enforce that the Increment should be either null or greater than the minimum.
116
+ * @param int|null $value The value to set.
117
+ * @throws InvalidArgumentException
118
+ */
119
+ public function setIncrement ($ value ) {
120
+ if ( !(is_null ($ value ) || is_int ($ value )) || (is_int ($ value ) && $ value < $ this ->config ()->minimum_increment ) ) {
121
+ throw new InvalidArgumentException ('The increment must be greater than ' . $ this ->config ()->minimum_increment . ' seconds. ' );
122
+ }
123
+ $ this ->setField ('Increment ' , $ value );
124
+ }
113
125
}
You can’t perform that action at this time.
0 commit comments