public function load($manager) { $result = array(); foreach ($this->data as $record) { $testHistory = new History; $testHistory->setTimestamp(new \DateTime); foreach ($record as $key => $val) { if ($key == 'job') { $job = new Job; $job->setCreateDate(new \DateTime); foreach ($val as $k => $v) { $job->{'set'.ucwords($k)}($v); } $val = $job; $manager->persist($val); unset($job); } $testHistory->{'set'.ucwords($key)}($val); } $manager->persist($testHistory); array_push($result, $testHistory); $manager->flush(); unset($testHistory); } return $result; }
public function load($manager) { $result = array(); foreach ($this->data as $record) { $testJob = new Job; $testJob->setCreateDate(new \DateTime); foreach ($record as $key => $val) { $testJob->{'set'.ucwords($key)}($val); } $manager->persist($testJob); array_push($result, $testJob); $manager->flush(); unset($testJob); } return $result; }
/** * Duplicates a job with similar properties to the original. * * @return NineThousand\Jobqueue\Vendor\Doctrine\Adapter\Job\DoctrineJobAdapter */ public function spawn() { $entity = new JobEntity; $entity->setRetry($this->_jobEntity->getRetry()); $entity->setCooldown($this->_jobEntity->getCooldown()); $entity->setMaxRetries($this->_jobEntity->getMaxRetries()); $entity->setAttempts(0); $entity->setExecutable($this->_jobEntity->getExecutable()); $entity->setType($this->_jobEntity->getType()); $entity->setStatus(null); $entity->setCreateDate(new \DateTime("now")); $entity->setLastRunDate(null); $entity->setActive(1); $entity->setSchedule(null); $entity->setParent($this->_jobEntity->getId()); $this->_em->persist($entity); $this->_em->flush(); //instantiate duplicated job adapter and set params, args, tags $jobAdapter = new self($this->_options, $entity, $this->_em, $this->_logger); if (count($params = $this->getParams())) $jobAdapter->setParams($params); if (count($args = $this->getArgs())) $jobAdapter->setArgs($args); if (count($tags = $this->getTags())) $jobAdapter->setTags($tags); return $jobAdapter; }