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

Cron. More...

Public Member Functions

array __construct (protected EventsService $events, protected 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
 

Detailed Description

Cron.

Definition at line 18 of file Cron.php.

Constructor & Destructor Documentation

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

Constructor.

Parameters
EventsService$eventsEvents service
Translator$translatorTranslator service

Definition at line 43 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 185 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 103 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 133 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 282 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 250 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 305 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 209 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 352 of file Cron.php.

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

Rotate the log files.

Parameters
string$intervalcron interval
Returns
void

Definition at line 328 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 55 of file Cron.php.

Member Data Documentation

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

Definition at line 25 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: