Blesta Source Documentation

Cron extends AppController

The Cron controller. Handles all automated tasks that run via a cron job or scheduled task.

Table of Contents

Properties

$cron_tasks
$passphrase
$task_factory
$task_filter
$task_options

Methods

addPaidPendingServices() Runs the add paid pending services task
all() Run all cron tasks
applyCredits() Runs the apply credits task
applyInvoiceLateFees() Runs the apply invoice late fees task
autoDebitInvoices() Runs the autodebit invoices task
cancelScheduledServices() Runs the cancel scheduled services task
cardExpirationReminders() Runs the card expiration reminder task
cleanLogs() Runs the clean-up logs task
createInvoices() Runs the create invoice task
deliverInvoices() Runs the deliver invoices task
deliverReports() Runs the deliver reports task
index() Runs the cron
lowBalanceNotifications() Runs the low balance notifications task
moduleTasks() Runs all module tasks
paymentReminders() Runs the payment reminders task
pluginTasks() Runs all plugin tasks
preAction() Pre-action
processRenewingServices() Runs the process renewing services task
processServiceChanges() Runs the process service changes task
suspendServices() Runs the suspend services task
transitionQuotations() Runs the transition quotations task
unsuspendServices() Runs the unsuspend services task
updateExchangeRates() Runs the update exchange rates task
allSystem() Runs all system-level cron tasks
amazonS3Backup() Runs the AmazonS3 database backup task (system)
appendCronTaskLastRun() Updates the given $cron_task to append the last run dates
createCronLogGroup() Creates a cron log group
getCronTask() Retrieves a cron task
isCurrentDay() Determines whether today is the day of the month given
isTimeToRun() Determines whether a cron task is enabled and if it is time for the task to run or not
license() Runs the system task to call home and validate the license
logTaskCompleted() Logs to the cron that a current task has been completed
logTaskStarted() Logs to the cron that a task has started
parseTaskFilter() Parses and validates the task filter configuration from JSON
resetErrors() Reset Input errors on a given object
runExtensionTypeTasks() Runs all cron tasks for a specific extension type (plugin or module)
setOutput() Sets output data
sftpBackup() Runs the SFTP database backup task (system)
shouldRunTask() Determines whether a task should run based on the current filter configuration
taskFactory() Create an instance of the TaskFactory
Properties

$cron_tasks

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

A list of cron task settings for the current company

$passphrase

private string $passphrase = \null

The passphrase used to process batch payments

$task_factory

private TaskFactory $task_factory

An instance of the TaskFactory

$task_filter

private array<string|int, mixed>|null $task_filter = \null

Task filter configuration (include/exclude tasks)

$task_options

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

An array of task options

Methods

addPaidPendingServices()

Runs the add paid pending services task

public addPaidPendingServices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

all()

Run all cron tasks

public all([string $cron_log_group = null ]) : false
Parameters
$cron_log_group : string = null

The name of the group associated with the log (optional)

Return values
false

applyCredits()

Runs the apply credits task

public applyCredits([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

applyInvoiceLateFees()

Runs the apply invoice late fees task

public applyInvoiceLateFees([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

autoDebitInvoices()

Runs the autodebit invoices task

public autoDebitInvoices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

cancelScheduledServices()

Runs the cancel scheduled services task

public cancelScheduledServices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

cardExpirationReminders()

Runs the card expiration reminder task

public cardExpirationReminders([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

cleanLogs()

Runs the clean-up logs task

public cleanLogs([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

createInvoices()

Runs the create invoice task

public createInvoices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

deliverInvoices()

Runs the deliver invoices task

public deliverInvoices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

deliverReports()

Runs the deliver reports task

public deliverReports([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

index()

Runs the cron

public index() : mixed

lowBalanceNotifications()

Runs the low balance notifications task

public lowBalanceNotifications([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

moduleTasks()

Runs all module tasks

public moduleTasks([string $cron_log_group = null ]) : bool
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

Return values
bool

false to not render a view

paymentReminders()

Runs the payment reminders task

public paymentReminders([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

pluginTasks()

Runs all plugin tasks

public pluginTasks([string $cron_log_group = null ]) : bool
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

Return values
bool

false to not render a view

preAction()

Pre-action

public preAction() : mixed

processRenewingServices()

Runs the process renewing services task

public processRenewingServices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

processServiceChanges()

Runs the process service changes task

public processServiceChanges([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

suspendServices()

Runs the suspend services task

public suspendServices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

transitionQuotations()

Runs the transition quotations task

public transitionQuotations([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

unsuspendServices()

Runs the unsuspend services task

public unsuspendServices([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

updateExchangeRates()

Runs the update exchange rates task

public updateExchangeRates([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

allSystem()

Runs all system-level cron tasks

private allSystem() : mixed

amazonS3Backup()

Runs the AmazonS3 database backup task (system)

private amazonS3Backup([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

appendCronTaskLastRun()

Updates the given $cron_task to append the last run dates

private appendCronTaskLastRun(stdClass $cron_task) : stdClass
Parameters
$cron_task : stdClass

The cron task

Return values
stdClass

The cron task appended with:

  • date_last_started The last run date started
  • date_last_completed The last run date ended

createCronLogGroup()

Creates a cron log group

private createCronLogGroup() : string
Return values
string

The cron log group

getCronTask()

Retrieves a cron task

private getCronTask(string $cron_task_key[, string $dir = null ][, bool $system = false ][, string $task_type = 'system' ]) : mixed
Parameters
$cron_task_key : string

The cron task key of the cron task to get

$dir : string = null

The directory this cron task is associated with

$system : bool = false

True if the task is a system-level task, false if it is company-level (optional, default false)

$task_type : string = 'system'

The type of cron task this is (i.e. 'system', 'module', or 'plugin', default 'system')

Return values
mixed

An stdClass representing the cron task, or false if none exist

isCurrentDay()

Determines whether today is the day of the month given

private isCurrentDay(int $day) : bool
Parameters
$day : int

The day of the month to check (i.e. in range [1,31])

Return values
bool

True if today is the current day given, false otherwise

isTimeToRun()

Determines whether a cron task is enabled and if it is time for the task to run or not

private isTimeToRun(stdClass $cron_task[, bool $system = false ]) : bool
Parameters
$cron_task : stdClass

An stdClass object representing the cron task

$system : bool = false

True if the task is a system-level task, false if it is company-level (optional, default false)

Return values
bool

True if this cron task can be run, false otherwise

license()

Runs the system task to call home and validate the license

private license([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

logTaskCompleted()

Logs to the cron that a current task has been completed

private logTaskCompleted(int $run_id, string $event, string $cron_log_group, string $end_date, string $output[, string $key = null ]) : mixed
Parameters
$run_id : int

The run ID of this event

$event : string

The event to log

$cron_log_group : string

The cron log group that this event is apart of

$end_date : string

The start date of the task in Y-m-d H:i:s format

$output : string

The output from running the task

$key : string = null

The key of the cron task (optional)

Return values
mixed

An array of errors, or false if there are no errors

logTaskStarted()

Logs to the cron that a task has started

private logTaskStarted(int $run_id, string $event, string $cron_log_group, string $start_date[, string $output = null ][, string $key = null ]) : mixed
Parameters
$run_id : int

The run ID of this event

$event : string

The event to log

$cron_log_group : string

The cron log group that this event is apart of

$start_date : string

The start date of the task in Y-m-d H:i:s format

$output : string = null

The output from running the task (optional)

$key : string = null

The key of the cron task (optional)

Return values
mixed

An array of errors, or false if there are no errors

parseTaskFilter()

Parses and validates the task filter configuration from JSON

private parseTaskFilter(string $json_filter) : array<string|int, mixed>|null
Parameters
$json_filter : string

The JSON filter string

Return values
array<string|int, mixed>|null

The parsed filter configuration, or null on error

resetErrors()

Reset Input errors on a given object

private resetErrors(object $object) : mixed
Parameters
$object : object

An instance of an object containing the Input component

runExtensionTypeTasks()

Runs all cron tasks for a specific extension type (plugin or module)

private runExtensionTypeTasks(string $extension_type, string $cron_log_group) : bool

This method handles filtering and execution of tasks for plugins and modules.

Parameters
$extension_type : string

The extension type ('plugin' or 'module')

$cron_log_group : string

The cron log group that this event is apart of (optional, default null)

Return values
bool

False on success or error to not render a view

setOutput()

Sets output data

private setOutput(string $new[, string $old = '' ][, bool $echo = true ]) : string
Parameters
$new : string

The new output data

$old : string = ''

The old output data, if any (optional, default "")

$echo : bool = true

True to output the new text

Return values
string

A concatenation of the old and new output

sftpBackup()

Runs the SFTP database backup task (system)

private sftpBackup([string $cron_log_group = null ]) : mixed
Parameters
$cron_log_group : string = null

The cron log group that this event is apart of (optional, default null)

shouldRunTask()

Determines whether a task should run based on the current filter configuration

private shouldRunTask(string $task_identifier) : bool
Parameters
$task_identifier : string

The task identifier to check

Return values
bool

True if the task should run, false otherwise

taskFactory()

Create an instance of the TaskFactory

private taskFactory() : TaskFactory
Return values
TaskFactory

The task factory

Tags
subpackage

app.controllers

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

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

link

Blesta


        
On this page

Search results