Elgg  Version 5.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Cron Class Reference

Cron. More...

Public Member Functions

 __construct (EventsService $events, Translator $translator)
 Constructor. More...
 
 run (array $intervals=null, bool $force=false)
 Executes handlers for periods that have elapsed since last cron. More...
 
 getLogs (string $interval, bool $filenames_only=false)
 Get the log files for a given cron interval. More...
 
 getLastCompletion (string $interval)
 Get the time of the last completion of a cron interval. More...
 
 getConfiguredIntervals (bool $only_names=false)
 Get the cron interval configuration. More...
 

Protected Member Functions

 before (string $interval,\Elgg\Logger\Cron $cron_logger,\DateTime $time=null)
 Execute commands before cron interval is run. More...
 
 execute (string $interval,\Elgg\Logger\Cron $cron_logger, string $filename,\DateTime $time=null)
 Execute handlers attached to a specific cron interval. More...
 
 after (string $output, string $interval,\Elgg\Logger\Cron $cron_logger)
 Printers handler result. More...
 
 getLogFilename (string $interval,\DateTime $time=null)
 Get a filename to log in. More...
 
 rotateLogs (string $interval)
 Rotate the log files. More...
 
 logCompletion (string $interval)
 Log the completion time of a cron interval. More...
 

Protected Attributes

const LOG_FILES_TO_KEEP = 5
 
array $default_intervals
 
array EventsService $events
 
Translator $translator
 

Detailed Description

Cron.

Definition at line 18 of file Cron.php.

Constructor & Destructor Documentation

Elgg\Cron::__construct ( EventsService  $events,
Translator  $translator 
)

Constructor.

Parameters
EventsService$eventsEvents service
Translator$translatorTranslator service

Definition at line 47 of file Cron.php.

Member Function Documentation

Elgg\Cron::after ( string  $output,
string  $interval,
\Elgg\Logger\Cron  $cron_logger 
)
protected

Printers handler result.

Parameters
string$outputOutput string
string$intervalInterval name
\Elgg\Logger\Cron$cron_loggerCron logger
Returns
void

Definition at line 214 of file Cron.php.

Elgg\Cron::before ( string  $interval,
\Elgg\Logger\Cron  $cron_logger,
\DateTime  $time = null 
)
protected

Execute commands before cron interval is run.

Parameters
string$intervalInterval name
\Elgg\Logger\Cron$cron_loggerCron logger
null | \DateTime$timeTime of the cron initialization (default: current service time)
Returns
void

Definition at line 109 of file Cron.php.

Elgg\Cron::execute ( string  $interval,
\Elgg\Logger\Cron  $cron_logger,
string  $filename,
\DateTime  $time = null 
)
protected

Execute handlers attached to a specific cron interval.

Parameters
string$intervalCron interval to execute
\Elgg\Logger\Cron$cron_loggerCron logger
string$filenameFilename of the cron log
null | \DateTime$timeTime of cron initialization (default: current service time)
Returns
string

Definition at line 139 of file Cron.php.

Elgg\Cron::getConfiguredIntervals ( bool  $only_names = false)

Get the cron interval configuration.

Parameters
bool$only_namesOnly return the names of the intervals
Returns
array
Since
3.2

Definition at line 311 of file Cron.php.

Elgg\Cron::getLastCompletion ( string  $interval)

Get the time of the last completion of a cron interval.

Parameters
string$intervalcron interval
Returns
null|DateTime

Definition at line 279 of file Cron.php.

Elgg\Cron::getLogFilename ( string  $interval,
\DateTime  $time = null 
)
protected

Get a filename to log in.

Parameters
string$intervalcron interval to log
\DateTime | null$timestart time of the cron
Returns
string

Definition at line 334 of file Cron.php.

Elgg\Cron::getLogs ( string  $interval,
bool  $filenames_only = false 
)

Get the log files for a given cron interval.

The results are sorted so the newest log is the first in the array

Parameters
string$intervalcron interval
bool$filenames_onlyonly return the filenames (default: false)
Returns
array

Definition at line 238 of file Cron.php.

Elgg\Cron::logCompletion ( string  $interval)
protected

Log the completion time of a cron interval.

Parameters
string$intervalcron interval
Returns
void

Definition at line 381 of file Cron.php.

Elgg\Cron::rotateLogs ( string  $interval)
protected

Rotate the log files.

Parameters
string$intervalcron interval
Returns
void

Definition at line 357 of file Cron.php.

Elgg\Cron::run ( array  $intervals = null,
bool  $force = false 
)

Executes handlers for periods that have elapsed since last cron.

Parameters
null | array$intervalsInterval names to run (default: all cron intervals)
bool$forceForce cron jobs to run even they are not yet due
Returns
Job[]
Exceptions
CronException

Definition at line 61 of file Cron.php.

Member Data Documentation

array Elgg\Cron::$default_intervals
protected
Initial value:
= [
'minute' => '* * * * *'

Definition at line 25 of file Cron.php.

array EventsService Elgg\Cron::$events
protected
Initial value:
=> '*/5 * * * *',
'fifteenmin' => '*/15 * * * *',
'halfhour' => '*/30 * * * *',
'hourly' => '0 * * * *',
'daily' => '0 0 * * *',
'weekly' => '0 0 * * 0',
'monthly' => '0 0 1 * *',
'yearly' => '0 0 1 1 *',
]

Definition at line 27 of file Cron.php.

Translator Elgg\Cron::$translator
protected

Definition at line 39 of file Cron.php.

const Elgg\Cron::LOG_FILES_TO_KEEP = 5
protected

Definition at line 23 of file Cron.php.


The documentation for this class was generated from the following file: