|
| registerTask ($task, $active=true) |
|
| unregisterTask ($task_id) |
|
| scheduleOnce ($task_id, $timestamp, $priority=CronjobSchedule::PRIORITY_NORMAL, $parameters=[]) |
|
| schedulePeriodic ($task_id, $minute=null, $hour=null, $day=null, $month=null, $day_of_week=null, $priority=CronjobSchedule::PRIORITY_NORMAL, $parameters=[]) |
|
| cancel ($schedule_id) |
|
| cancelByTask ($task_id) |
|
| run () |
|
◆ cancel()
Cancels the provided schedule.
- Parameters
-
String | $schedule_id | Id of the schedule to be canceled |
◆ cancelByTask()
Cancels all schedules of the provided task.
- Parameters
-
String | $task_id | Id of the task which schedules shall be canceled |
◆ getInstance()
Returns the scheduler object. Implements the singleton pattern to ensure that only one scheduler exists.
- Returns
- CronjobScheduler The scheduler object
◆ registerTask()
registerTask |
( |
|
$task, |
|
|
|
$active = true |
|
) |
| |
Registers a new executable task.
- Parameters
-
mixed | $task | Either path of the task class filename (relative to Stud.IP root) or an instance of CronJob |
bool | $active | Indicates whether the task should be set active or not |
- Returns
- String Id of the created task
- Exceptions
-
InvalidArgumentException | when the task class file does not exist |
RuntimeException | when task has already been registered |
◆ run()
Executes the available schedules if they are to be executed. This method can only be run once - even if one execution takes more than planned. This is ensured by a locking mechanism.
◆ scheduleOnce()
Schedules a task for a single execution at the provided time.
- Parameters
-
String | $task_id | The id of the task to be executed |
int | $timestamp | When the task should be executed |
String | $priority | Priority of the execution (low, normal, high), defaults to normal |
Array | $parameters | Optional parameters passed to the task |
- Returns
- CronjobSchedule The generated schedule object.
◆ schedulePeriodic()
schedulePeriodic |
( |
|
$task_id, |
|
|
|
$minute = null , |
|
|
|
$hour = null , |
|
|
|
$day = null , |
|
|
|
$month = null , |
|
|
|
$day_of_week = null , |
|
|
|
$priority = CronjobSchedule::PRIORITY_NORMAL , |
|
|
|
$parameters = [] |
|
) |
| |
Schedules a task for periodic execution with the provided schedule.
- Parameters
-
String | $task_id | The id of the task to be executed |
mixed | $minute | Minute part of the schedule:
- null for "every minute" a.k.a. "don't care"
- x < 0 for "every x minutes"
- x >= 0 for "only at minute x"
|
mixed | $hour | Hour part of the schedule:
- null for "every hour" a.k.a. "don't care"
- x < 0 for "every x hours"
- x >= 0 for "only at hour x"
|
mixed | $day | Day part of the schedule:
- null for "every day" a.k.a. "don't care"
- x < 0 for "every x days"
- x > 0 for "only at day x"
|
mixed | $month | Month part of the schedule:
- null for "every month" a.k.a. "don't care"
- x < 0 for "every x months"
- x > 0 for "only at month x"
|
mixed | $day_of_week | Day of week part of the schedule:
- null for "every day" a.k.a. "don't care"
- 1 >= x >= 7 for "exactly at day of week x" (x starts with monday at 1 and ends with sunday at 7)
|
String | $priority | Priority of the execution (low, normal, high), defaults to normal |
Array | $parameters | Optional parameters passed to the task |
- Returns
- CronjobSchedule The generated schedule object.
◆ unregisterTask()
unregisterTask |
( |
|
$task_id | ) |
|
Unregisters a previously registered task.
- Parameters
-
String | $task_id | Id of the task to be unregistered |
- Returns
- CronjobScheduler to allow chaining
- Exceptions
-
InvalidArgumentException | when no task with the given id exists |
◆ $instance
The documentation for this class was generated from the following file: