period = $period; return $this; } /** * Returns the duration of pause between two runs of the job. * * @return float */ public function getPauseDuration() { return $this->period; } /** * {@inheritdoc} */ final protected function doRun(JobDataInterface $data = null) { if (!$data instanceof JobData) { // removes lock files, unregister tick handlers $this->finish(); throw new InvalidArgumentException('JobData must be passed to a JobInterface::Run command.'); } $this->setPauseDuration($data->getTask()->getPeriod()); try { $this->doJob($data); } catch (\Exception $e) { $this->finish(); $this->log('error', sprintf('Error while running %s : %s', $this->getName(), $e->getMessage())); throw $e; } } /** * Does execute the job * * @param JobData $data The data */ abstract protected function doJob(JobData $data); }