dolibarr 25.0.0-alpha
Cronjobs Class Reference
Inheritance diagram for Cronjobs:
Collaboration diagram for Cronjobs:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get properties of a cron job object.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $status=-1, $sqlfilters='', $properties='', $pagination_data=false)
 List cron jobs.
 
 post ($request_data=null)
 Create cron job object.
 
 put ($id, $request_data=null)
 Update cron job fields.
 
 delete ($id)
 Delete cron job.
 
 run ($id, $securitykey='')
 Run a cron job now.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas @phpstan-template T.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _checkValExtrafieldsForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _filterObjectProperties ($object, $properties)
 Filter properties that will be returned on object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Private Member Functions

 _validate ($data)
 Validate fields before create or update object.
 

Additional Inherited Members

- Static Protected Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $parenttableforentity='')
 Check access by user to a given resource.
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string.
 

Detailed Description

Definition at line 28 of file api_cronjobs.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Cronjobs::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties @phpstan-param T $object @phpstan-return T

Reimplemented from DolibarrApi.

Definition at line 305 of file api_cronjobs.class.php.

References $object.

Referenced by get(), index(), and run().

◆ _validate()

Cronjobs::_validate ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,string>$data Array with data to verify
Returns
array<string,string>
Exceptions
RestException

Definition at line 322 of file api_cronjobs.class.php.

Referenced by post().

◆ delete()

Cronjobs::delete ( $id)

Delete cron job.

Parameters
int$idCron job ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}
Exceptions
RestException

Definition at line 217 of file api_cronjobs.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ get()

Cronjobs::get ( $id)

Get properties of a cron job object.

Return an array with cron job information

Parameters
int$idID of cron job
Returns
Object Object with cleaned properties
Exceptions
RestException

Definition at line 63 of file api_cronjobs.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

◆ index()

Cronjobs::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$status = -1,
$sqlfilters = '',
$properties = '',
$pagination_data = false )

List cron jobs.

Get a list of cron jobs

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
int$statusFilter on status (-1=no filter, 0=disabled, 1=enabled, 2=archived)
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%foo%')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
bool$pagination_dataIf this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0
Returns
array Array of cron job objects @phan-return Cronjob[]|array{data:Cronjob[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return Cronjob[]|array{data:Cronjob[],pagination:array{total:int,page:int,page_count:int,limit:int}}
Exceptions
RestException

Definition at line 100 of file api_cronjobs.class.php.

References _cleanObjectDatas(), and DolibarrApi\_filterObjectProperties().

◆ post()

Cronjobs::post ( $request_data = null)

Create cron job object.

Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of cron job
Exceptions
RestException

Definition at line 148 of file api_cronjobs.class.php.

References DolibarrApi\_checkValForAPI(), and _validate().

◆ put()

Cronjobs::put ( $id,
$request_data = null )

Update cron job fields.

Parameters
int$idId of cron job to update
array$request_dataData @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Updated object
Exceptions
RestException

Definition at line 178 of file api_cronjobs.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and DolibarrApi\_checkValForAPI().

◆ run()

Cronjobs::run ( $id,
$securitykey = '' )

Run a cron job now.

Runs the job synchronously, in the current API request (there is no asynchronous job queue: this call blocks until the job finishes, exactly like the "Execute" button on the cron job card). The job's own success/failure is reported in the returned object (lastresult / lastoutput / datelastresult), it does not by itself make this call fail.

Parameters
int$idCron job ID
string$securitykeySecurity key, mandatory only if the CRON_KEY global constant is set {@from query}

@url POST {id}/run

Returns
Object
Exceptions
RestException

Definition at line 261 of file api_cronjobs.class.php.

References $id, DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), dol_now(), and getDolGlobalString().


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