Пример #1
0
 /**
  * Runs a job by handing it over to
  *
  * @param Enlight_Components_Cron_Job $job
  * @return Enlight_Event_EventArgs
  * @throw Enlight_Exception
  */
 public function runJob(Enlight_Components_Cron_Job $job)
 {
     // Fix cron action name
     $action = $job->getAction();
     if (strpos($action, 'Shopware_') !== 0) {
         $action = str_replace(' ', '', ucwords(str_replace('_', ' ', $job->getAction())));
         $job->setAction('Shopware_CronJob_' . $action);
     }
     try {
         if ($this->adapter->startJob($job)) {
             $jobArgs = new $this->eventArgsClass(array('subject' => $this, 'job' => $job));
             $jobArgs->setReturn($job->getData());
             $jobArgs = $this->eventManager->notifyUntil($job->getAction(), $jobArgs);
             if ($jobArgs !== null) {
                 $job->setData($jobArgs->getReturn());
                 $this->adapter->updateJob($job);
             }
             $this->endJob($job);
             return $jobArgs;
         }
     } catch (Exception $e) {
         $job->setData(array('error' => $e->getMessage()));
         $this->disableJob($job);
         throw $e;
     }
 }
Пример #2
0
 /**
  * Runs a job by handing it over to
  *
  * @param Enlight_Components_Cron_Job $job
  * @return Enlight_Event_EventArgs
  * @throw Enlight_Exception
  */
 public function runJob(Enlight_Components_Cron_Job $job)
 {
     try {
         if ($this->adapter->startJob($job)) {
             $jobArgs = new $this->eventArgsClass(array('subject' => $this, 'job' => $job));
             $jobArgs->setReturn($job->getData());
             $jobArgs = $this->eventManager->notifyUntil($job->getAction(), $jobArgs);
             if ($jobArgs !== null) {
                 $job->setData($jobArgs->getReturn());
                 $this->adapter->updateJob($job);
             }
             $this->endJob($job);
             return $jobArgs;
         }
     } catch (Exception $e) {
         $job->setData(array('error' => $e->getMessage()));
         $this->disableJob($job);
         throw $e;
     }
 }