Piwik\Plugin\

Tasks

Base class for all Tasks declarations.

Tasks are usually meant as scheduled tasks that are executed regularly by Matomo (formerly Piwik) in the background. For instance once every hour or every day. This could be for instance checking for updates, sending email reports, etc. Please don't mix up tasks with console commands which can be executed on the CLI.

Methods

The class defines the following methods:

  • hourly() — Schedule the given tasks/method to run once every hour.
  • daily() — Schedule the given tasks/method to run once every day.
  • weekly() — Schedule the given tasks/method to run once every week.
  • monthly() — Schedule the given tasks/method to run once every month.
  • custom() — Schedules the given tasks/method to run depending at the given scheduled time.

hourly()

Schedule the given tasks/method to run once every hour.

Signature

  • It accepts the following parameter(s):

    • $methodName

    • $methodParameter

    • $priority

    • $ttlInSeconds (int|null) —

  • It returns a Schedule value.

daily()

Schedule the given tasks/method to run once every day.

See hourly()

Signature

  • It accepts the following parameter(s):

    • $methodName

    • $methodParameter

    • $priority

    • $ttlInSeconds (int|null) —

  • It does not return anything or a mixed result.

weekly()

Schedule the given tasks/method to run once every week.

See hourly()

Signature

  • It accepts the following parameter(s):

    • $methodName

    • $methodParameter

    • $priority

    • $ttlInSeconds (int|null) —

  • It does not return anything or a mixed result.

monthly()

Schedule the given tasks/method to run once every month.

See hourly()

Signature

  • It accepts the following parameter(s):

    • $methodName

    • $methodParameter

    • $priority

    • $ttlInSeconds (int|null) —

  • It does not return anything or a mixed result.

custom()

Schedules the given tasks/method to run depending at the given scheduled time. Unlike the convenient methods such as hourly() you need to specify the object on which the given method should be called. This can be either an instance of a class or a class name. For more information about these parameters see hourly()

Signature

  • It accepts the following parameter(s):

    • $objectOrClassName

    • $methodName

    • $methodParameter

    • $time

    • $priority

    • $ttlInSeconds (int|null) —

  • It returns a Schedule value.

  • It throws one of the following exceptions:
    • Exception — If a wrong time format is given. Needs to be either a string such as 'daily', 'weekly', ... or an instance of {@link Piwik\Scheduler\Schedule\Schedule}