示例#1
0
 /**
  *
  */
 public function testGetData()
 {
     $data = "A String";
     $this->assertArrayCount(2, $this->job->getData());
     $this->assertInstanceOf('Enlight_Components_Cron_Job', $this->job->setData($data));
     $this->assertEquals($data, $this->job->getData());
 }
示例#2
0
 /**
  * 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);
 }
示例#3
0
 /**
  * {@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()]);
     }
 }