/** * Sets the job ticket in $record['extra']['job_ticket'] * * {@inheritdoc} */ protected function write(array $record) { $log = $this->manager->create(); $record['extra']['job_ticket'] = $this->job->getTicket(); $this->populateLog($log, $record); $this->manager->save($log); }
public function deleteByJob(JobInterface $job) { $path = $this->buildPath($job->getTicket()); $filesystem = new Filesystem(); if ($filesystem->exists($path)) { $filesystem->remove($path); } }
/** * Updates a schedule * * @ParamType("type", type="string") * @ParamType("expression", type="string") * * @param string $type * @param string $expression */ public function updateSchedule($type, $expression) { $schedule = new Schedule(); $schedule->setType($type); $schedule->setExpression($expression); $this->job->removeSchedules(); $this->job->addSchedule($schedule); }
/** * Invokes the job. * * @param JobInterface $job * @param ContextInterface $context * @return mixed * @throws JobTypeNotFoundException */ public function invoke(JobInterface $job, ContextInterface $context) { $jobType = $this->registry->get($job->getType()); $callableArray = $jobType->getCallable(); $parameters = static::resolveParameters($jobType, $context, $job->getParameters()); if (is_array($callableArray) && ($callable = $callableArray[0])) { if ($callable instanceof JobAwareInterface) { $callable->setJob($job); } if ($callable instanceof ManagerAwareInterface) { $callable->setManager($this->manager); } if ($callable instanceof ControllerAwareInterface) { $callable->setController($this->controllerFactory->create($job)); } if ($callable instanceof LoggerAwareInterface && $context->has('abc.logger')) { $callable->setLogger($context->get('abc.logger')); } } return call_user_func_array($callableArray, $parameters); }
/** * Copies properties of a job to another job * * @param JobInterface $from The job where properties are copied from * @param \Abc\Bundle\JobBundle\Model\JobInterface $to The job where where properties are copied to * @return \Abc\Bundle\JobBundle\Model\JobInterface The copied job */ public function copyJob(JobInterface $from, \Abc\Bundle\JobBundle\Model\JobInterface $to) { $to->setType($from->getType()); $to->setResponse($from->getResponse()); $to->setParameters($from->getParameters()); if (null != $from->getStatus()) { $to->setStatus($from->getStatus()); } foreach ($from->getSchedules() as $schedule) { $to->addSchedule($schedule); } return $to; }
/** * Get lock name for job object * * @param JobInterface $job * @return string */ private function getLockName(JobInterface $job) { return self::JOB_LOCK_PREFIX . $job->getTicket(); }
/** * {@inheritdoc} */ public function createHandler(JobInterface $job, $level, $bubble) { $handler = new StreamHandler($this->buildPath($job->getTicket()), $level, $bubble); return $this->initHandler($handler); }
/** * {@inheritdoc} */ public function deleteByJob(BaseJobInterface $job) { return $this->deleteLogs($this->findBy(['jobTicket' => $job->getTicket()])); }
/** * @param JobInterface $job * @return string The channel name */ protected function buildChannel(JobInterface $job) { return $job->getTicket(); }