RdbAdmin Module

Cron
in package

Cron class.

Tags
since
0.1

Table of Contents

Properties

$Cache  : CacheInterface
$cacheBasedPath  : string
$Container  : Container

Methods

__construct()  : mixed
Class constructor.
cacheHadRun()  : bool
Set cache that cron job had already run.
getSecondsBeforeNext()  : int
Get seconds before next run date/time and maybe subtract 1 minute, 10 seconds (for unit in minute).
hasRun()  : bool
Check that cron job has run or not.
runJobsOnAllModules()  : array<string|int, mixed>
Run jobs on all enabled modules.
getCallerClass()  : string
Get caller class.
isEnableCron()  : bool
Check if cron is enabled.

Properties

$Cache

protected CacheInterface $Cache

$cacheBasedPath

protected string $cacheBasedPath = STORAGE_PATH . '/cache/Modules/RdbAdmin/Libraries/Cron'

The cache based folder.

$Container

protected Container $Container

Methods

__construct()

Class constructor.

public __construct(Container $Container) : mixed
Parameters
$Container : Container

The DI container class.

cacheHadRun()

Set cache that cron job had already run.

public cacheHadRun(int|DateInterval $ttl) : bool
Parameters
$ttl : int|DateInterval

The expire date/time. This should related to your cron job time. For example: Your cron job run every hour (0 minute, 0 second) then this should be ((next hour timestamp in 0 minute 0 second - 1 minute) - current timestamp), Your cron job run every day (0 midnight, 0 minute, 0 second) then this should be ((next day timestamp in 0 hour 0 minute 0 second - 1 minute) - current timestamp)

Return values
bool

Return true on success write the cache, false for otherwise.

getSecondsBeforeNext()

Get seconds before next run date/time and maybe subtract 1 minute, 10 seconds (for unit in minute).

public getSecondsBeforeNext([string $unit = 'day' ][, bool $subtract = true ]) : int
Parameters
$unit : string = 'day'

Accepted unit is 'minute', 'hour', 'day'

$subtract : bool = true

Set to true (default) to subtract few time before next date/time. This is for allow it to be expired before time. Set to false to not subtract.

Tags
throws
Throw

the errors if unknown unit argument was set.

Return values
int

Return number of seconds minus 1 minute before next run date/time.

hasRun()

Check that cron job has run or not.

public hasRun() : bool
Return values
bool

Return true if it had already run, false for otherwise.

runJobsOnAllModules()

Run jobs on all enabled modules.

public runJobsOnAllModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

Return associative array of runned cron job.

getCallerClass()

Get caller class.

protected getCallerClass() : string
Return values
string

Return class or file name.

isEnableCron()

Check if cron is enabled.

protected isEnableCron() : bool
Return values
bool

Return true if enabled, false for not.


        
On this page

Search results