public function addFeaturesStatus($type, $value = 1) { $newFeatureStatus = new kFeatureStatus(); $newFeatureStatus->setType($type); $newFeatureStatus->setValue($value); $this->putInCustomData($type, $newFeatureStatus, 'featuresStatuses'); $this->save(); }
public function resetFeaturesStatusByType($type) { $openStatuses = array(BatchJob::BATCHJOB_STATUS_ALMOST_DONE, BatchJob::BATCHJOB_STATUS_RETRY, BatchJob::BATCHJOB_STATUS_PENDING, BatchJob::BATCHJOB_STATUS_QUEUED, BatchJob::BATCHJOB_STATUS_PROCESSING, BatchJob::BATCHJOB_STATUS_PROCESSED, BatchJob::BATCHJOB_STATUS_MOVEFILE); $criteria = new Criteria(); $criteria->add(BatchJobPeer::PARTNER_ID, $this->getId()); $criteria->add(BatchJobPeer::JOB_TYPE, BatchJobType::INDEX); $criteria->add(BatchJobPeer::JOB_SUB_TYPE, $type); $criteria->add(BatchJobPeer::STATUS, $openStatuses, Criteria::IN); $batchJob = BatchJobPeer::doSelectOne($criteria); $featuresStatuses = $this->getFeaturesStatus(); if ($batchJob) { $newFeatureStatus = new kFeatureStatus(); $newFeatureStatus->setType($type); $newFeatureStatus->setValue(1); $featuresStatuses[$type] = $newFeatureStatus; } elseif (isset($featuresStatuses[$type])) { unset($featuresStatuses[$type]); } $this->setFeaturesStatus($featuresStatuses); $this->setUpdatedAt(time()); $this->save(); }