コード例 #1
0
ファイル: EventArgs.php プロジェクト: nvdnkpr/Enlight
 /**
  * Standard constructor method, the cron job are required.
  * If the job data property is a string, it will be unserialized.
  * @param Enlight_Components_Cron_Job $job
  */
 public function __construct(Enlight_Components_Cron_Job $job)
 {
     $data = $job->getData();
     if (is_string($data)) {
         $data = unserialize($data);
     }
     $this->job = $job;
     parent::__construct($job->getAction(), $data);
 }
コード例 #2
0
ファイル: DBAL.php プロジェクト: GerDner/luck-docker
 /**
  * {@inheritdoc}
  */
 public function updateJob(Enlight_Components_Cron_Job $job)
 {
     $data = [];
     $data['action'] = $job->getAction();
     $data[$this->connection->quoteIdentifier('interval')] = $job->getInterval();
     $data['data'] = serialize($job->getData());
     $data['active'] = $job->getActive() ? '1' : '0';
     $data['next'] = $job->getNext() ? $job->getNext()->toString('YYYY-MM-dd HH:mm:ss') : null;
     $data['start'] = $job->getStart() ? $job->getStart()->toString('YYYY-MM-dd HH:mm:ss') : null;
     $data['end'] = $job->getEnd() ? $job->getEnd()->toString('YYYY-MM-dd HH:mm:ss') : null;
     if (is_null($job->getId())) {
         $this->connection->insert($this->tableName, $data);
     } else {
         $this->connection->update($this->tableName, $data, ['id' => $job->getId()]);
     }
 }
コード例 #3
0
ファイル: Manager.php プロジェクト: GerDner/luck-docker
 /**
  * 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;
     }
 }
コード例 #4
0
ファイル: JobTest.php プロジェクト: nvdnkpr/Enlight
 /**
  * @todo Implement testSetAction().
  */
 public function testSetAction()
 {
     $this->assertInstanceOf('Enlight_Components_Cron_Job', $this->job->setAction('test_action'));
     $this->assertEquals('test_action', $this->job->getAction());
 }