* @access public
*
*/
+ /**
+ *
+ */
public function __construct() {
$config = CRM_Core_Config::singleton();
$config->fatalErrorHandler = 'CRM_Core_JobManager_scheduledJobFatalErrorHandler';
* @access private
*
*/
+ /**
+ * @param bool $auth
+ */
public function execute($auth = TRUE) {
$this->logEntry('Starting scheduled jobs execution');
*/
public function __destruct() {}
+ /**
+ * @param $entity
+ * @param $action
+ */
public function executeJobByAction($entity, $action) {
$job = $this->_getJob(NULL, $entity, $action);
$this->executeJob($job);
}
+ /**
+ * @param $id
+ */
public function executeJobById($id) {
$job = $this->_getJob($id);
$this->executeJob($job);
* @access private
*
*/
+ /**
+ * @return array
+ */
private function _getJobs() {
$jobs = array();
$dao = new CRM_Core_DAO_Job();
* @access private
*
*/
+ /**
+ * @param null $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');
return $job;
}
+ /**
+ * @param $entity
+ * @param $job
+ * @param $params
+ * @param null $source
+ */
public function setSingleRunParams($entity, $job, $params, $source = NULL) {
$this->_source = $source;
$key = strtolower($entity . '_' . $job);
* @access public
*
*/
+ /**
+ * @param $message
+ */
public function logEntry($message) {
$domainID = CRM_Core_Config::domainID();
$dao = new CRM_Core_DAO_JobLog();
$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!');
}
}
+/**
+ * @param $message
+ *
+ * @throws Exception
+ */
function CRM_Core_JobManager_scheduledJobFatalErrorHandler($message) {
throw new Exception("{$message['message']}: {$message['code']}");
}