Piwik\Scheduler\

Task

Describes a task that should be executed on a given time.

See the TaskScheduler docs to learn more about scheduled tasks.

Methods

The class defines the following methods:

  • __construct()
  • getObjectInstance() — Returns the object instance that contains the method to execute.
  • getClassName() — Returns the name of the class that contains the method to execute.
  • getMethodName() — Returns the name of the method that will be executed.
  • getMethodParameter() — Returns the value that will be passed to the method when executed, or null if no value will be supplied.
  • getScheduledTime() — Returns a Schedule instance that describes when the method should be executed and how long before the next execution.
  • getRescheduledTime() — Returns the time in milliseconds when this task will be executed next.
  • getPriority() — Returns the task priority.
  • getTTL() — Returns the TTL for this task.
  • getName() — Returns a unique name for this scheduled task.

__construct()

Signature

  • It accepts the following parameter(s):
    • $objectInstance (mixed) — The object or class that contains the method to execute regularly. Usually this will be a Plugin instance.
    • $methodName (string) — The name of the method that will be regularly executed.
    • $methodParameter (mixed|null) — An optional parameter to pass to the method when executed. Must be convertible to string.
    • $scheduledTime (Schedule|null) — A Schedule instance that describes when the method should be executed and how long before the next execution.
    • $priority (int) — The priority of the task. Tasks with a higher priority will be executed first. Tasks with low priority will be executed last.
    • $ttlInSeconds (int) — TTL to use for this task. Defauts to 3600. See self::$ttlInSeconds
  • It throws one of the following exceptions:

getObjectInstance()

Returns the object instance that contains the method to execute. Returns a class name if the method is static.

Signature

  • It returns a mixed value.

getClassName()

Returns the name of the class that contains the method to execute.

Signature

  • It returns a string value.

getMethodName()

Returns the name of the method that will be executed.

Signature

  • It returns a string value.

getMethodParameter()

Returns the value that will be passed to the method when executed, or null if no value will be supplied.

Signature

  • Returns: string|null

getScheduledTime()

Returns a Schedule instance that describes when the method should be executed and how long before the next execution.

Signature

getRescheduledTime()

Returns the time in milliseconds when this task will be executed next.

Signature

  • It returns a int value.

getPriority()

Returns the task priority. The priority will be an integer whose value is between HIGH_PRIORITY and LOW_PRIORITY.

Signature

  • It returns a int value.

getTTL()

Returns the TTL for this task.

See self::$ttlInSeconds

Signature

  • It returns a int value.

getName()

Returns a unique name for this scheduled task. The name is stored in the DB and is used to store a task's previous execution time. The name is created using:

  • the name of the class that contains the method to execute,
  • the name of the method to regularly execute,
  • and the value that is passed to the executed task.

Signature

  • It returns a string value.