/** * {@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()]); } }
/** * Writes the Job object to the database. If an ID is provided this method will try to update a data set. If there * is no ID given, the system will create a new data set. * * @param Enlight_Components_Cron_Job $job * @return Enlight_Components_Cron_Adapter_Adapter */ public function write(Enlight_Components_Cron_Job $job) { $data = array(); $where = null; foreach ($this->_columns as $key => $value) { switch ($key) { case 'data': $data[$key] = serialize($job->{$key}); break; default: $data[$key] = $job->{$key}; } } if (is_null($job->getId())) { $next = $job->getNext(); if (empty($next)) { $job->setNext(new Zend_Date()); } $start = $job->getStart(); if (empty($start)) { $zd = new Zend_Date(); $job->setStart($zd->subDay(1)); } $end = $job->getEnd(); if (empty($end)) { $zd = new Zend_Date(); $job->setEnd($zd->subDay(1)); } $this->insert($data); } else { $where = $this->getAdapter()->quoteInto($this->getAdapter()->quoteIdentifier($this->_primary) . ' = ?', $job->getId()); $this->update($data, $where); } return $this; }
/** * @todo Implement testGetEnd(). */ public function testGetEnd() { $this->assertEquals($this->jobData['end'], $this->job->getEnd()); }