This object manages cron job adding/deleting/locking

uses the database link
uses a result from database
uses the current user
uses get temporary filename and request begin time
uses the exceptions handler
uses get the HTTP queries time
uses implements the singleton pattern
package OWR
used_by \OWR\CLI\Controller
used_by \OWR\Model\Streams
used_by \OWR\REST\Controller
used_by \OWR\Controller

 Methods

Cloning is denied This function can NOT be overloaded

__clone() 
Inherited
access public
author Pierre-Alain Mignot
inherited_from \OWR\Singleton::__clone()

Destructor It will unlink the locking file for the current action if not already done (strange but if errors.

__destruct() 

.) and writes the new crontab if any

author Pierre-Alain Mignot
access public

Executed when an object is unserialized We register the new object

__wakeUp() 
Inherited
access public
author Pierre-Alain Mignot
inherited_from \OWR\Singleton::__wakeUp()

Logs the end of the script execution

abort(string $action) 
access public
author Pierre-Alain Mignot

Parameters

$action

string

the name of the action aborted

Gets the minimum time to live from streams

getMinTtl() : int
access public
author Pierre-Alain Mignot

Returns

intttl

Instance getter This function can NOT be overloaded

iGet() : mixed
InheritedStatic
access public
static
author Pierre-Alain Mignot
inherited_from \OWR\Singleton::iGet()

Returns

mixedthe instance

Checks that the action is not locked This function checks that the locking file exists

isLocked(string $action) : boolean
access public
author Pierre-Alain Mignot

Parameters

$action

string

the name of the action to check

Returns

booleantrue if locked

"touch" a file into the cache directory This function is used to lock a cron action, preventing multiple jobs doing the same action

lock(string $action) : boolean
access public
author Pierre-Alain Mignot

Parameters

$action

string

the name of the action to lock

Returns

booleantrue on success

Manages Cron adding/removing

manage(mixed $args) 
author Pierre-Alain Mignot
access public

Parameters

$args

mixed

the arguments

Register function This function is called when an object is unserialized and is used to register the instance of the object This function can NOT be overloaded

register(mixed $instance) 
InheritedStatic
access public
static
author Pierre-Alain Mignot
inherited_from \OWR\Singleton::register()

Parameters

$instance

mixed

the instance to register

Deletes a file from the cache directory This function is used to unlock a cron action

unlock(string $action, boolean $error) : boolean
access public
author Pierre-Alain Mignot

Parameters

$action

string

the name of the action to unlock

$error

boolean

has the end of the script been triggered by an error ?

Returns

booleantrue on success

Constructor

__construct() 
access public

Adds/Edits a cron job This function has been adapted from http://matthieu.developpez.com/execution_periodique, thanks to the author

_add(string $type, int $hour, int $minute, int $monthDay, int $weekDay, int $month, string $cmd, string $comment) : string
access protected
author Pierre-Alain Mignot
link for uncommented parameters

Parameters

$type

string

name of the action

$hour

int

$minute

int

$monthDay

int

$weekDay

int

$month

int

$cmd

string

the command to execute

$comment

string

a comment for this cron job

Returns

string$type

Deletes a cron job This function has been adapted from http://matthieu.developpez.com/execution_periodique, thanks to the author

_delete(string $type) : string
access protected
author Pierre-Alain Mignot

Parameters

$type

string

name of the action

Returns

string$type

Writes the new crontab

_write() 
author Pierre-Alain Mignot
access protected

 Properties

 

the new crontab lines

$_cronTab : array
access protected
 

name of the current action

$_currentAction : string
access protected
 

has the crontab changed ?

$_hasChanged : boolean
access protected
 

is a cron job locked ?

$_isLocked : boolean
access protected
 

minimum ttl found in database

$_minCronTtl : int
access protected
 

url of the current installation

$_url : string
access protected
 

store instancied objects

$_instances : array
Inherited
access private
static
inherited_from \OWR\Singleton::$$_instances

 Constants

 

<p>begin line of crontab</p>

CRON_START : string
 

<p>end line of crontab</p>

CRON_STOP : string
access protected