Blesta Source Documentation

AbstractCron implements AutomationTypeInterface, LoggableInterface

AbstractYes

Base abstract class for representing a Blesta cron task.

Also provides for logging task output to the cron log.

Attributes
#[AllowDynamicProperties]
Table of Contents

Interfaces

AutomationTypeInterface Simple interface for defining automation type methods
LoggableInterface Simple interface for logging content

Properties

$date
$logEvent
$logged
$loggedContent
$options
$task

Methods

__construct() Initialize the cron task with cron task data
canRun() Determines whether the automation type can be run given a date
log() Logs the given content to the cron log
logComplete() Marks the current cron task log complete
raw() Retrieves the raw input for this task
getDefaultOptions() Retrieves default options expected of cron tasks
getRoundedInterval() Rounds down the given timestamp to the nearest interval
taskIntervalPast() Determines whether the task's run interval has passed
taskTimePast() Determines whether the task's run time has passed
Properties

$date

private Date $date

An instance of Minphp\Date\Date

$logEvent

private The $logEvent = 1

log event for this log session

$logged

private Whether $logged = false

or not this task has written a cron log yet

$loggedContent

private The $loggedContent = ''

string content currently logged to the cron log

$options

private array<string|int, mixed> $options = []

An array of key/value pairs

Methods

__construct()

Initialize the cron task with cron task data

public __construct(stdClass $task, Date $date[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$task : stdClass

An stdClass object containing:

  • id The cron task ID
  • key The cron task key
  • name The name of the cron task
  • type The type of cron task (e.g. interval or time)
  • task_run_id The ID of the runnable task
  • company_id The ID of the company
  • time The time of day to run the task
  • interval The time interval to run the task
  • enabled Whether or not the task is enabled
  • date_enabled The date timestamp that the task was enabled
  • date_last_started The date timestamp that the task last started
  • date_last_completed The date timestamp that the task last completed
  • plugin_id The ID of the plugin associated with the cron task
  • plugin_dir The plugin directory
  • plugin_name The name of the plugin associated with the cron task
  • plugin_version The version of the plugin associated with the cron task
  • plugin_enabled Whether or not the plugin is enabled
$date : Date
$options : array<string|int, mixed> = []

An array of options, including:

  • log_group The name of the cron log group to use for logging purposes

canRun()

Determines whether the automation type can be run given a date

public canRun(mixed $date) : bool
Parameters
$date : mixed

A date timestamp representing the date the automation type may be run at

Return values
bool

True if the automation type may be run, or false otherwise

log()

Logs the given content to the cron log

public log(string $content) : mixed
Parameters
$content : string

The content to log

logComplete()

Marks the current cron task log complete

public logComplete() : mixed

raw()

Retrieves the raw input for this task

public raw() : stdClass
Return values
stdClass

An stdClass object representing the cron task

getDefaultOptions()

Retrieves default options expected of cron tasks

private getDefaultOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of key/value pairs

getRoundedInterval()

Rounds down the given timestamp to the nearest interval

private getRoundedInterval(string $dateTime) : int
Parameters
$dateTime : string

The date timestamp to round down to the nearest interval

Return values
int

The UNIX timestamp of the nearest interval

taskIntervalPast()

Determines whether the task's run interval has passed

private taskIntervalPast(string $date[, string|null $lastStartDate = null ]) : bool
Parameters
$date : string

The date timestamp

$lastStartDate : string|null = null

The UTC timestamp that the task last began

Return values
bool

True if the interval date has passed, or false otherwise

taskTimePast()

Determines whether the task's run time has passed

private taskTimePast(string $date[, string|null $lastStartDate = null ][, string|null $lastEndDate = null ]) : bool
Parameters
$date : string

The date timestamp

$lastStartDate : string|null = null

The UTC timestamp that the task last began

$lastEndDate : string|null = null

The UTC timestamp that the task last ended

Return values
bool

True if the interval date has passed, or false otherwise

Tags
subpackage

core.Automation.Type.Cron

copyright

Copyright (c) 2018, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results