コード例 #1
0
 public final function execute($qOptions = array())
 {
     // Tests should be run via run() not execute()
     $config = Mage::getConfig();
     $q = new ZendJobQueue();
     $jqOpts = $config->getModuleConfig('ZendServer_JobQueue');
     if (!isset($jqOpts->jobqueue) && !isset($jqOpts->jobqueue->url)) {
         throw new ZendServer_JobQueue_Job_Exception('Missing the jobqueue configuration directive');
     }
     $qOptions = array_merge(array('name' => get_class($this)), $qOptions);
     $ret = $q->createHttpJob($jqOpts->jobqueue->url, array('obj' => base64_encode(serialize($this))), $qOptions);
     return $ret;
 }
コード例 #2
0
 public function sendAction()
 {
     $params = \ZendJobQueue::getCurrentJobParams();
     $issue = $this->issueResource->fetch($params['issueId']);
     unset($params['issueId']);
     $params['issue'] = $issue;
     return false;
 }
コード例 #3
0
 public function shareIssueAction()
 {
     $identity = $this->getEvent()->getParam('ZF\\MvcAuth\\Identity');
     if ($identity instanceof \ZF\MvcAuth\Identity\AuthenticatedIdentity) {
         $userId = $identity->getAuthenticationIdentity()['user_id'];
         $user = $this->pdoAdapter->getUserDetails($userId);
     } else {
         //TODO : ApiProblem because no identity
     }
     $data = $this->bodyParams();
     $id = $this->params()->fromRoute('id');
     $data['issueId'] = $id;
     $data['sender'] = trim($user['first_name'] . ' ' . $user['last_name']);
     $jq = new \ZendJobQueue();
     $url = $this->url()->fromRoute('application/default', array('controller' => 'mail', 'action' => 'send'));
     $jobId = $jq->createHttpJob($url, $data, array());
     return compact('jobId');
 }
コード例 #4
0
 /**
  * The default action - show the home page
  */
 public function emailAction()
 {
     $params = ZendJobQueue::getCurrentJobParams();
     // TODO: throw exception when not called from a job, in the init method?
     if (!$this->_helper->requestValidation($params['password'])) {
         ZendJobQueue::setCurrentJobStatus(ZendJobQueue::FAILED);
         // TODO: not very nice, should be logged
         exit('Terminated, validation error!');
     }
     $mail = new Zend_Mail();
     $mail->setBodyText($params['body']);
     $mail->setFrom('*****@*****.**', 'SimpleCal Admin');
     $mail->addTo($params['to']);
     $mail->setSubject($params['subject']);
     #$mail->send();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
 }
コード例 #5
0
 public function indexAction()
 {
     $params = ZendJobQueue::getCurrentJobParams();
     if (isset($params['obj'])) {
         $obj = unserialize(base64_decode($params['obj']));
         if ($obj instanceof ZendServer_JobQueue_Job_Abstract) {
             try {
                 $obj->run();
                 ZendJobQueue::setCurrentJobStatus(ZendJobQueue::OK);
                 exit;
             } catch (Exception $e) {
                 zend_monitor_set_aggregation_hint(get_class($obj) . ': ' . $e->getMessage());
                 zend_monitor_custom_event('Failed Job', $e->getMessage());
             }
         }
     }
     ZendJobQueue::setCurrentJobStatus(ZendJobQueue::FAILED);
     exit;
 }
コード例 #6
0
 public function reinventAction()
 {
     $eventId = $this->_getParam('id');
     $queue = new ZendJobQueue();
     $jobQuery = array('name' => self::JOB_INVITATION_PREFIX . $eventId);
     $jobList = $queue->getJobsList($jobQuery);
     foreach ($jobList as $job) {
         $queue->restartJob($job['id']);
     }
     $this->_redirect('/');
 }
コード例 #7
0
ファイル: post_activate.php プロジェクト: bcremer/mwop.net
<?php

$server = 'https://mwop.net';
$queue = new ZendJobQueue();
// First, remove any existing job schedules for our application
foreach ($queue->getSchedulingRules() as $job) {
    if (0 !== strpos($job['script'], $server)) {
        // Job is not one we're interested in
        continue;
    }
    // Remove a previously scheduled job
    $queue->deleteSchedulingRule($job['id']);
}
// Add scheduled job for fetching comics
$queue->createHttpJob($server . '/jobs/comics', [], ['name' => 'comics', 'persistent' => false, 'schedule' => '0 10 * * *']);
// Add scheduled job for fetching github feed
$queue->createHttpJob($server . '/jobs/github-feed', [], ['name' => 'github-feed', 'persistent' => false, 'schedule' => '5,20,35,40 * * * *']);
// Schedule an immediate cache clear
$queue->createHttpJob($server . '/jobs/clear-cache', [], ['name' => 'clear-cache', 'persistent' => false]);