Scheduler implements SingletonInterface

TYPO3 Scheduler. This class handles scheduling and execution of tasks.

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$extConf  : array<string|int, mixed>
$logger  : LoggerInterface

Methods

__construct()  : mixed
Constructor, makes sure all derived client classes are included
addTask()  : bool
Adds a task to the pool
executeTask()  : bool
This method executes the given task and properly marks and records that execution It is expected to return FALSE if the task was barred from running or if it was not saved properly
fetchTask()  : AbstractTask|null
Fetches and unserializes a task object from the db. If a uid is given the object with the uid is returned, else the object representing the next due task is returned.
fetchTaskRecord()  : array<string|int, mixed>
This method is used to get the database record for a given task It returns the database record and not the task object
fetchTasksWithCondition()  : array<string|int, mixed>
Fetches and unserializes task objects selected with some (SQL) condition Objects are returned as an array
isValidTaskObject()  : bool
This method encapsulates a very simple test for the purpose of clarity.
log()  : mixed
This is a utility method that writes some message to the BE Log It could be expanded to write to some other log
recordLastRun()  : mixed
This method stores information about the last run of the Scheduler into the system registry
removeTask()  : bool
Removes a task completely from the system.
saveTask()  : bool
Updates a task in the pool
cleanExecutionArrays()  : mixed
Cleans the execution lists of the scheduled tasks, executions older than 24h are removed

Properties

$extConf

public array<string|int, mixed> $extConf = []

Settings from the extension manager

Methods

__construct()

Constructor, makes sure all derived client classes are included

public __construct(LoggerInterface $logger) : mixed
Parameters
$logger : LoggerInterface

addTask()

Adds a task to the pool

public addTask(AbstractTask $task) : bool
Parameters
$task : AbstractTask

The object representing the task to add

Return values
bool

TRUE if the task was successfully added, FALSE otherwise

executeTask()

This method executes the given task and properly marks and records that execution It is expected to return FALSE if the task was barred from running or if it was not saved properly

public executeTask(AbstractTask $task) : bool
Parameters
$task : AbstractTask

The task to execute

Tags
throws
Throwable
Return values
bool

Whether the task was saved successfully to the database or not

fetchTask()

Fetches and unserializes a task object from the db. If a uid is given the object with the uid is returned, else the object representing the next due task is returned.

public fetchTask([int $uid = 0 ]) : AbstractTask|null

If there are no due tasks the method throws an exception.

Parameters
$uid : int = 0

Primary key of a task

Tags
throws
OutOfBoundsException
throws
UnexpectedValueException
Return values
AbstractTask|null

The fetched task object

fetchTaskRecord()

This method is used to get the database record for a given task It returns the database record and not the task object

public fetchTaskRecord(int $uid) : array<string|int, mixed>
Parameters
$uid : int

Primary key of the task to get

Tags
see
Scheduler::fetchTask()
throws
OutOfBoundsException
Return values
array<string|int, mixed>

Database record for the task

fetchTasksWithCondition()

Fetches and unserializes task objects selected with some (SQL) condition Objects are returned as an array

public fetchTasksWithCondition(string $where[, bool $includeDisabledTasks = false ]) : array<string|int, mixed>
Parameters
$where : string

Part of a SQL where clause (without the "WHERE" keyword)

$includeDisabledTasks : bool = false

TRUE if disabled tasks should be fetched too, FALSE otherwise

Return values
array<string|int, mixed>

List of task objects

isValidTaskObject()

This method encapsulates a very simple test for the purpose of clarity.

public isValidTaskObject(object $task) : bool

Registered tasks are stored in the database along with a serialized task object. When a registered task is fetched, its object is unserialized. At that point, if the class corresponding to the object is not available anymore (e.g. because the extension providing it has been uninstalled), the unserialization will produce an incomplete object. This test checks whether the unserialized object is of the right (parent) class or not.

Parameters
$task : object

The object to test

Return values
bool

TRUE if object is a task, FALSE otherwise

log()

This is a utility method that writes some message to the BE Log It could be expanded to write to some other log

public log(string $message[, int $status = 0 ][, mixed $code = '' ]) : mixed
Parameters
$message : string

The message to write to the log

$status : int = 0

Status (0 = message, 1 = error)

$code : mixed = ''

Key for the message

recordLastRun()

This method stores information about the last run of the Scheduler into the system registry

public recordLastRun([string $type = 'cron' ]) : mixed
Parameters
$type : string = 'cron'

Type of run (manual or command-line (assumed to be cron))

removeTask()

Removes a task completely from the system.

public removeTask(AbstractTask $task) : bool
Parameters
$task : AbstractTask

The object representing the task to delete

Tags
todo

find a way to actually kill the existing jobs

Return values
bool

TRUE if task was successfully deleted, FALSE otherwise

saveTask()

Updates a task in the pool

public saveTask(AbstractTask $task) : bool
Parameters
$task : AbstractTask

Scheduler task object

Return values
bool

False if submitted task was not of proper class

cleanExecutionArrays()

Cleans the execution lists of the scheduled tasks, executions older than 24h are removed

protected cleanExecutionArrays() : mixed
Tags
todo

find a way to actually kill the job


        
On this page

Search results