X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FJobManager.php;h=6798a12f832f365b53c39642fcfa17e3ac95cf37;hb=d09edf64e678a73669cff34014a55a06604de75a;hp=e9755e071f61d0c8646a24997d200fa8528ec12d;hpb=bfc6355af6949ca1e4a7c39d0f54f0ec70b641bf;p=civicrm-core.git diff --git a/CRM/Core/JobManager.php b/CRM/Core/JobManager.php index e9755e071f..6798a12f83 100644 --- a/CRM/Core/JobManager.php +++ b/CRM/Core/JobManager.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * This interface defines methods that need to be implemented @@ -51,12 +51,10 @@ class CRM_Core_JobManager { var $_source = NULL; - /* - * Class constructor - * - * @param void - */ /** + * Class constructor. + * + * @return void */ public function __construct() { $config = CRM_Core_Config::singleton(); @@ -65,10 +63,6 @@ class CRM_Core_JobManager { $this->jobs = $this->_getJobs(); } - /* - * - * @param void - */ /** * @param bool $auth */ @@ -93,12 +87,11 @@ class CRM_Core_JobManager { $this->logEntry('Finishing scheduled jobs execution.'); } - /* - * Class destructor - * - * @param void + /** + * Class destructor. */ - public function __destruct() {} + public function __destruct() { + } /** * @param $entity @@ -137,24 +130,20 @@ class CRM_Core_JobManager { try { $result = civicrm_api($job->api_entity, $job->api_action, $params); } - catch(Exception$e) { + catch (Exception$e) { $this->logEntry('Error while executing ' . $job->name . ': ' . $e->getMessage()); } $this->logEntry('Finished execution of ' . $job->name . ' with result: ' . $this->_apiResultToMessage($result)); $this->currentJob = FALSE; } - /* + /** * Retrieves the list of jobs from the database, * populates class param. * - * @param void * @return array * ($id => CRM_Core_ScheduledJob) */ - /** - * @return array - */ private function _getJobs() { $jobs = array(); $dao = new CRM_Core_DAO_Job(); @@ -169,13 +158,10 @@ class CRM_Core_JobManager { return $jobs; } - /* - * Retrieves specific job from the database by id + /** + * Retrieves specific job from the database by id. * and creates ScheduledJob object. * - * @param void - */ - /** * @param int $id * @param null $entity * @param null $action @@ -187,8 +173,8 @@ class CRM_Core_JobManager { if (is_null($id) && is_null($action)) { CRM_Core_Error::fatal('You need to provide either id or name to use this method'); } - $dao = new CRM_Core_DAO_Job(); - $dao->id = $id; + $dao = new CRM_Core_DAO_Job(); + $dao->id = $id; $dao->api_entity = $entity; $dao->api_action = $action; $dao->find(); @@ -212,12 +198,11 @@ class CRM_Core_JobManager { $this->singleRunParams[$key]['version'] = 3; } - /* - * - * @return array|null collection of permissions, null if none - */ /** - * @param $message + * @param string $message + * + * @return void + * collection of permissions, null if none */ public function logEntry($message) { $domainID = CRM_Core_Config::domainID(); @@ -229,10 +214,10 @@ class CRM_Core_JobManager { $dao->description .= " (...)"; } if ($this->currentJob) { - $dao->job_id = $this->currentJob->id; - $dao->name = $this->currentJob->name; + $dao->job_id = $this->currentJob->id; + $dao->name = $this->currentJob->name; $dao->command = ts("Entity:") . " " . $this->currentJob->api_entity . " " . ts("Action:") . " " . $this->currentJob->api_action; - $data = ""; + $data = ""; if (!empty($this->currentJob->parameters)) { $data .= "\n\nParameters raw (from db settings): \n" . $this->currentJob->parameters; } @@ -259,8 +244,8 @@ class CRM_Core_JobManager { */ private function _apiResultToMessage($apiResult) { $status = $apiResult['is_error'] ? ts('Failure') : ts('Success'); - $msg = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!'); - $vals = CRM_Utils_Array::value('values', $apiResult, 'empty values!'); + $msg = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!'); + $vals = CRM_Utils_Array::value('values', $apiResult, 'empty values!'); if (is_array($msg)) { $msg = serialize($msg); } @@ -270,6 +255,7 @@ class CRM_Core_JobManager { $message = $apiResult['is_error'] ? ', Error message: ' . $msg : " (" . $vals . ")"; return $status . $message; } + } /**