Merge pull request #4818 from pratikshad/CRM-15770
[civicrm-core.git] / CRM / Core / JobManager.php
index f8f0198a36cf174d52e447d1546185defd0a0496..87f31061ab2339b39113561c2ea0d97912c5d144 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -55,7 +55,9 @@ class CRM_Core_JobManager {
    * Class constructor
    *
    * @param void
-   * @access public
+   *
+   */
+  /**
    *
    */
   public function __construct() {
@@ -68,9 +70,11 @@ class CRM_Core_JobManager {
   /*
    *
    * @param void
-   * @access private
    *
    */
+  /**
+   * @param bool $auth
+   */
   public function execute($auth = TRUE) {
 
     $this->logEntry('Starting scheduled jobs execution');
@@ -96,16 +100,22 @@ class CRM_Core_JobManager {
    * Class destructor
    *
    * @param void
-   * @access public
    *
    */
   public function __destruct() {}
 
+  /**
+   * @param $entity
+   * @param $action
+   */
   public function executeJobByAction($entity, $action) {
     $job = $this->_getJob(NULL, $entity, $action);
     $this->executeJob($job);
   }
 
+  /**
+   * @param int $id
+   */
   public function executeJobById($id) {
     $job = $this->_getJob($id);
     $this->executeJob($job);
@@ -144,9 +154,11 @@ class CRM_Core_JobManager {
    *
    * @param void
    * @return array ($id => CRM_Core_ScheduledJob)
-   * @access private
    *
    */
+  /**
+   * @return array
+   */
   private function _getJobs() {
     $jobs = array();
     $dao = new CRM_Core_DAO_Job();
@@ -166,9 +178,16 @@ class CRM_Core_JobManager {
    * and creates ScheduledJob object.
    *
    * @param void
-   * @access private
    *
    */
+  /**
+   * @param int $id
+   * @param null $entity
+   * @param null $action
+   *
+   * @return CRM_Core_ScheduledJob
+   * @throws Exception
+   */
   private function _getJob($id = NULL, $entity = NULL, $action = NULL) {
     if (is_null($id) && is_null($action)) {
       CRM_Core_Error::fatal('You need to provide either id or name to use this method');
@@ -185,6 +204,12 @@ class CRM_Core_JobManager {
     return $job;
   }
 
+  /**
+   * @param $entity
+   * @param $job
+   * @param array $params
+   * @param null $source
+   */
   public function setSingleRunParams($entity, $job, $params, $source = NULL) {
     $this->_source = $source;
     $key = strtolower($entity . '_' . $job);
@@ -195,9 +220,11 @@ class CRM_Core_JobManager {
   /*
    *
    * @return array|null collection of permissions, null if none
-   * @access public
    *
    */
+  /**
+   * @param $message
+   */
   public function logEntry($message) {
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_JobLog();
@@ -210,7 +237,7 @@ class CRM_Core_JobManager {
     if ($this->currentJob) {
       $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;
+      $dao->command = ts("Entity:") . " " . $this->currentJob->api_entity . " " . ts("Action:") . " " . $this->currentJob->api_action;
       $data         = "";
       if (!empty($this->currentJob->parameters)) {
         $data .= "\n\nParameters raw (from db settings): \n" . $this->currentJob->parameters;
@@ -231,6 +258,11 @@ class CRM_Core_JobManager {
     $dao->save();
   }
 
+  /**
+   * @param $apiResult
+   *
+   * @return string
+   */
   private function _apiResultToMessage($apiResult) {
     $status = $apiResult['is_error'] ? ts('Failure') : ts('Success');
     $msg    = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!');
@@ -246,7 +278,11 @@ class CRM_Core_JobManager {
   }
 }
 
+/**
+ * @param $message
+ *
+ * @throws Exception
+ */
 function CRM_Core_JobManager_scheduledJobFatalErrorHandler($message) {
   throw new Exception("{$message['message']}: {$message['code']}");
 }
-