dolibarr 23.0.3
DataPolicyCron Class Reference

Class DataPolicyCron. More...

Public Member Functions

 __construct (DoliDB $db)
 Constructor.
 
 getDataPolicies ()
 Defines and returns the centralized data policy configuration.
 
 cleanDataForDataPolicy ()
 Main cron task execution method.
 

Private Member Functions

 _handleDelete ($object, $user, $policy)
 Handles the specific logic for deleting an object.
 
 _handleAnonymize ($object, $user, $policy)
 Handles the specific logic for anonymizing an object.
 
 _buildCallArguments ($object, $user, $policy, $method)
 Builds the dynamic argument list for method calls based on policy configuration.
 
 _recordActionResult ($result, $object, $action)
 Records the result of an action, updating counters and error messages.
 

Detailed Description

Class DataPolicyCron.

Definition at line 31 of file datapolicycron.class.php.

Constructor & Destructor Documentation

◆ __construct()

DataPolicyCron::__construct ( DoliDB $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 52 of file datapolicycron.class.php.

Member Function Documentation

◆ _buildCallArguments()

DataPolicyCron::_buildCallArguments ( $object,
$user,
$policy,
$method )
private

Builds the dynamic argument list for method calls based on policy configuration.

Parameters
CommonObject$objectThe target object.
User$userThe user object.
array<string,mixed>$policy The policy configuration.
'delete'|'update'$method The method key ('delete' or 'update').
Returns
mixed[] The list of arguments for the call.
Parameters
string$paramNameName of parameter to get
Returns
mixed Parameter value

Definition at line 453 of file datapolicycron.class.php.

References $object.

Referenced by _handleAnonymize(), and _handleDelete().

◆ _handleAnonymize()

DataPolicyCron::_handleAnonymize ( $object,
$user,
$policy )
private

Handles the specific logic for anonymizing an object.

Parameters
CommonObject$objectThe object to anonymize.
User$userThe user performing the action.
array<string,mixed>$policy The policy configuration.
Returns
int The result of the update operation, or 0 if skipped.

Definition at line 424 of file datapolicycron.class.php.

References $object, and _buildCallArguments().

◆ _handleDelete()

DataPolicyCron::_handleDelete ( $object,
$user,
$policy )
private

Handles the specific logic for deleting an object.

Parameters
CommonObject$objectThe object to delete.
User$userThe user performing the action.
array<string,mixed>$policy The policy configuration.
Returns
int The result of the delete operation.

Definition at line 409 of file datapolicycron.class.php.

References $object, and _buildCallArguments().

◆ _recordActionResult()

DataPolicyCron::_recordActionResult ( $result,
$object,
$action )
private

Records the result of an action, updating counters and error messages.

Parameters
int$resultThe result code from the action (<0 for error).
CommonObject$objectThe processed object.
string$actionThe action that was performed ('delete' or 'anonymize').
Returns
void

Definition at line 482 of file datapolicycron.class.php.

References $object.

◆ cleanDataForDataPolicy()

DataPolicyCron::cleanDataForDataPolicy ( )

Main cron task execution method.

Orchestrates the data cleaning process by iterating through all defined policies.

Returns
int Returns 0 for success, 1 for failure, as required for cron jobs.

Definition at line 282 of file datapolicycron.class.php.

References $object, and getDataPolicies().

◆ getDataPolicies()

DataPolicyCron::getDataPolicies ( )

Defines and returns the centralized data policy configuration.

Separating this makes the main method cleaner.

Returns
array<string, array<string, mixed>> The array of all data policies.

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

References Societe\CUSTOMER, Societe\CUSTOMER_AND_PROSPECT, dol_mktime(), img_picto(), isModEnabled(), Societe\NO_CUSTOMER, and Societe\PROSPECT.

Referenced by cleanDataForDataPolicy().


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