INFRA-132 add full stops
[civicrm-core.git] / CRM / Core / JobManager.php
index c1473b41da671dae20b28cfbbcc7dd38bc5425e5..6798a12f832f365b53c39642fcfa17e3ac95cf37 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -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,15 +51,10 @@ class CRM_Core_JobManager {
   var $_source = NULL;
 
 
-  /*
-   * Class constructor
-   *
-   * @param void
-   * @access public
-   *
-   */
   /**
+   * Class constructor.
    *
+   * @return void
    */
   public function __construct() {
     $config = CRM_Core_Config::singleton();
@@ -68,12 +63,6 @@ class CRM_Core_JobManager {
     $this->jobs = $this->_getJobs();
   }
 
-  /*
-   *
-   * @param void
-   * @access private
-   *
-   */
   /**
    * @param bool $auth
    */
@@ -98,14 +87,11 @@ class CRM_Core_JobManager {
     $this->logEntry('Finishing scheduled jobs execution.');
   }
 
-  /*
-   * Class destructor
-   *
-   * @param void
-   * @access public
-   *
+  /**
+   * Class destructor.
    */
-  public function __destruct() {}
+  public function __destruct() {
+  }
 
   /**
    * @param $entity
@@ -117,7 +103,7 @@ class CRM_Core_JobManager {
   }
 
   /**
-   * @param $id
+   * @param int $id
    */
   public function executeJobById($id) {
     $job = $this->_getJob($id);
@@ -144,24 +130,19 @@ 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)
-   * @access private
-   *
-   */
-  /**
    * @return array
+   *   ($id => CRM_Core_ScheduledJob)
    */
   private function _getJobs() {
     $jobs = array();
@@ -177,16 +158,11 @@ 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
-   * @access private
-   *
-   */
-  /**
-   * @param null $id
+   * @param int $id
    * @param null $entity
    * @param null $action
    *
@@ -197,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();
@@ -222,14 +198,11 @@ class CRM_Core_JobManager {
     $this->singleRunParams[$key]['version'] = 3;
   }
 
-  /*
-   *
-   * @return array|null collection of permissions, null if none
-   * @access public
-   *
-   */
   /**
-   * @param $message
+   * @param string $message
+   *
+   * @return void
+   *   collection of permissions, null if none
    */
   public function logEntry($message) {
     $domainID = CRM_Core_Config::domainID();
@@ -241,10 +214,10 @@ class CRM_Core_JobManager {
       $dao->description .= " (...)";
     }
     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;
-      $data         = "";
+      $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 = "";
       if (!empty($this->currentJob->parameters)) {
         $data .= "\n\nParameters raw (from db settings): \n" . $this->currentJob->parameters;
       }
@@ -271,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);
     }
@@ -282,6 +255,7 @@ class CRM_Core_JobManager {
     $message = $apiResult['is_error'] ? ', Error message: ' . $msg : " (" . $vals . ")";
     return $status . $message;
   }
+
 }
 
 /**
@@ -292,4 +266,3 @@ class CRM_Core_JobManager {
 function CRM_Core_JobManager_scheduledJobFatalErrorHandler($message) {
   throw new Exception("{$message['message']}: {$message['code']}");
 }
-