*
* Format is ($id => CRM_Core_ScheduledJob).
*
- * @var array
+ * @var CRM_Core_ScheduledJob[]
*/
public $jobs = NULL;
* Class constructor.
*/
public function __construct() {
- $this->jobs = $this->_getJobs();
+ $this->jobs = $this->getJobs();
}
/**
CRM_Core_BAO_StatusPreference::create($statusPref);
}
- /**
- * Class destructor.
- */
- public function __destruct() {
- }
-
/**
* @param $entity
* @param $action
*/
public function executeJobByAction($entity, $action) {
- $job = $this->_getJob(NULL, $entity, $action);
+ $job = $this->getJob(NULL, $entity, $action);
$this->executeJob($job);
}
* @param int $id
*/
public function executeJobById($id) {
- $job = $this->_getJob($id);
+ $job = $this->getJob($id);
$this->executeJob($job);
}
$result = $e;
}
CRM_Utils_Hook::postJob($job, $params, $result);
- $this->logEntry('Finished execution of ' . $job->name . ' with result: ' . $this->_apiResultToMessage($result));
+ $this->logEntry('Finished execution of ' . $job->name . ' with result: ' . $this->apiResultToMessage($result));
$this->currentJob = FALSE;
//Disable outBound option after executing the job.
* @return array
* ($id => CRM_Core_ScheduledJob)
*/
- private function _getJobs(): array {
+ private function getJobs(): array {
$jobs = [];
$dao = new CRM_Core_DAO_Job();
$dao->orderBy('name');
* @return CRM_Core_ScheduledJob
* @throws Exception
*/
- private function _getJob($id = NULL, $entity = NULL, $action = NULL) {
+ private function getJob($id = NULL, $entity = NULL, $action = NULL) {
if (is_null($id) && is_null($action)) {
throw new CRM_Core_Exception('You need to provide either id or name to use this method');
}
*
* @return string
*/
- private function _apiResultToMessage($apiResult) {
+ private function apiResultToMessage($apiResult) {
$status = ($apiResult['is_error'] ?? FALSE) ? ts('Failure') : ts('Success');
$msg = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!');
$vals = CRM_Utils_Array::value('values', $apiResult, 'empty values!');
class CRM_Core_ScheduledJob {
/**
+ * Job ID
+ *
* @var int
- * @deprecated
*/
- public $version = 3;
+ public $id;
/**
+ * Which Domain is this scheduled job for
+ *
* @var int
*/
- public $id;
+ public $domain_id;
+
+ /**
+ * Scheduled job run frequency.
+ *
+ * @var string
+ */
+ public $run_frequency;
+
+ /**
+ * When was this cron entry last run
+ *
+ * @var string
+ */
+ public $last_run;
+
+ /**
+ * When is this cron entry scheduled to run
+ *
+ * @var string
+ */
+ public $scheduled_run_date;
+
+ /**
+ * Title of the job
+ *
+ * @var string
+ */
+ public $name;
+
+ /**
+ * Description of the job
+ *
+ * @var string
+ */
+ public $description;
- public $name = NULL;
+ /**
+ * Entity of the job api call
+ *
+ * @var string
+ */
+ public $api_entity;
+
+ /**
+ * Action of the job api call
+ *
+ * @var string
+ */
+ public $api_action;
+
+ /**
+ * List of parameters to the command.
+ *
+ * @var string
+ */
+ public $parameters;
/**
+ * Is this job active?
+ *
+ * @var bool
+ */
+ public $is_active;
+
+ /**
+ * Class string
+ *
+ * Set as a URL, when the jobs template is rendered,
+ * but not set in other contexts
+ *
+ * @var string|null
+ */
+ public $action = NULL;
+
+ /**
+ * Action
+ *
* @var string
+ * @todo This seems to only ever be set to an empty string and passed through to job.tpl,
+ * where it is used a HTML `class`. Can this be removed?
*/
- public $parameters = '';
+ public $class;
+ /**
+ * Result of parsing multi-line `$parameters` string into an array
+ *
+ * @var array
+ */
public $apiParams = [];
+ /**
+ * Container for error messages
+ *
+ * @var array
+ */
public $remarks = [];
/**
* @param array $params
*/
public function __construct($params) {
- // Fixme - setting undeclared class properties!
foreach ($params as $name => $param) {
- $this->$name = $param;
+ if (property_exists($this, $name)) {
+ $this->$name = $param;
+ }
}
try {