Class \Prado\Util\Cron\TDbCronModule
TDbCronModule does everything that TCronModule does but stores the tasks and persistent data in its own database table.
The TDbCronModule allows for adding, updating, and removing tasks from the application and shell. It can log executing tasks to the table as well.
There are log maintenance methods and TDbCronCleanLogTask for cleaning the cron logs.
Runtime Tasks can be added for execution onEndRequest. Singleton tasks can be added to TDbCronModule, and scheduled to execute during Runtime at onEndRequest. Then if it does not execute onEndRequest, then the next shell cron will execute the task. This could occur if the user presses stop before the page completes.
Class hierarchy
- \Prado\Util\Cron\TDbCronModule implements IDbModule
- \Prado\Util\Cron\TCronModule implements IPermissions
- \Prado\TModule implements IModule
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 4.2.0
public
|
|
public
|
addRuntimeTask(TCronTask $task) : mixed
Adds a task to being run time. If this is the first runtime task this
method adds {@see executeRuntimeTasks} to TApplication::onEndRequest.
|
public
|
|
public
|
|
public
|
clearRuntimeTasks() : mixed
Clears all tasks from being run time, and removes the handler from onEndRequest.
|
public
|
executeRuntimeTasks([null|TApplication $sender = null ][, null|mixed $param = null ]) : int
This executes the Run Time Tasks, this method is automatically added
to TApplication::onEndRequest when there are RuntimeTasks via {@see addRuntimeTask}.
|
public
|
fxGetCronTaskInfos(TDbCronModule $cron, null $param) : mixed
the global event handling requests for cron task info
|
public
|
|
public
|
|
public
|
getCronLog(null|string $name, int $pageSize, int $offset[, null|bool $sortingDesc = null ]) : mixed
Gets the cron log table of specific named or all tasks.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
init(array<string|int, mixed>|TXmlElement $config) : mixed
Initializes the module. Keeps track of the configured tasks different than db tasks.
|
public
|
|
public
|
removeRuntimeTask(TCronTask $untask) : mixed
Removes a task from being run time. If there are no runtime tasks left
then it removes {@see executeRuntimeTasks} from TApplication::onEndRequest.
|
public
|
removeTask(string|TCronTask $untask) : bool
Removes a task from the database table.
This also removes the task from the current tasks, the taskRow, and runtime Tasks. This cannot remove tasks that are current configuration tasks. Only tasks that exist can be removed. |
public
|
|
public
|
setConnectionID(string $value) : mixed
Sets the ID of a TDataSourceConfig module.
The datasource module will be used to establish the DB connection for this cron module. |
public
|
|
public
|
|
public
|
|
public
|
updateTask(TCronTask $task) : bool
Updates a task from its unique name. If the Task is not in the DB it returns false
|
public
|
validateTask(array<string|int, mixed> $properties) : mixed
This checks for "name". The name cannot by '*' or have spaces, `, ', ", <, or >t characters.
|
protected
|
addTaskInternal(TCronTask $task[, bool $runtime = false ]) : bool
Adds a task to the database. Validates the name and cannot add a task with an existing name.
This updates the table row data as well. |
protected
|
createDbConnection() : TDbConnection
Creates the DB connection. If no ConnectionId is provided, then this
creates a sqlite database in runtime named 'cron.jobs'.
|
protected
|
|
protected
|
ensureTable() : mixed
checks for the table, and if not there and autoCreate, then creates the table else throw error.
|
protected
|
ensureTasks([bool $initConfigTasks = true ]) : array<string|int, TCronTask>
reads in all the tasks from the db, instances them if they are active db tasks.
otherwise the rows are kept for persistent data. |
protected
|
|
protected
|
|
protected
|
removeTaskInternal(TCronTask|string $untask) : bool
Removes a task from the database table.
This also removes the task from the current tasks, the taskRow, and runtime Tasks. This cannot remove tasks that are current configuration tasks. Only tasks that exist can be removed. |
protected
|
setPersistentData(string $name, object $task) : bool
Sets the lastExecTime and processCount for a task from the DB.
Also resets the lastExecTime when not in the DB |
protected
|
updateTaskInfo(TCronTask $task) : mixed
This updates the LastExecTime and ProcessCount in the database
|
protected
|
updateTaskInternal(TCronTask $task) : bool
Updates a task from its unique name. If the Task is not in the DB it returns false
|
public
mixed
|
NAME_VALIDATOR_REGEX
Name Regular Expression, no spaces, single or double quotes, less than or greater than, no percent, and cannot start with star
|
'/^[^\\s`\'\\"\\*<>%][^\\s`\'\\"<>%]*$/i'
|
public
mixed
|
PERM_CRON_ADD_TASK
|
'cron_add_task'
|
public
mixed
|
PERM_CRON_LOG_DELETE
|
'cron_log_delete'
|
public
mixed
|
PERM_CRON_LOG_READ
|
'cron_log_read'
|
public
mixed
|
PERM_CRON_REMOVE_TASK
|
'cron_remove_task'
|
public
mixed
|
PERM_CRON_UPDATE_TASK
|
'cron_update_task'
|