public function setCurrentJob(JobInterface $job = null)
    {
        if (null !== $job && null !== $this->getCurrentJob()) {
            throw new ResqueRuntimeException(
                sprintf(
                    'Cannot set current job to %s when current job is not null, current job is %s',
                    $job,
                    $this->getCurrentJob()
                )
            );
        }

        $this->currentJob = $job;

        // @todo dispatch event, or maybe called WorkerRegistry->persist?

        return $this;
    }
public function setCurrentJob(JobInterface $job = null)
    {
        if (null !== $job && null !== $this->getCurrentJob()) {
            throw new ResqueRuntimeException(
                sprintf(
                    'Cannot set current job to %s when current job is not null, current job is %s',
                    $job,
                    $this->getCurrentJob()
                )
            );
        }

        $this->currentJob = $job;

        // @todo dispatch event, or maybe called WorkerRegistry->persist?

        return $this;
    }
public function setCurrentJob ( JobInterface $ job = null ) { if ( null !== $ job && null !== $ this -> getCurrentJob ( ) ) { throw new ResqueRuntimeException ( sprintf ( 'Cannot set current job to %s when current job is not null, current job is %s' , $ job , $ this -> getCurrentJob ( ) ) ) ; } $ this -> currentJob = $ job ; // @todo dispatch event, or maybe called WorkerRegistry->persist? return $ this ; }
Set current job

Sets which job the worker is currently working on, and records it in redis.

@param JobInterface|null $job The job being worked on, or null if the worker isn't processing a job anymore.
@throws ResqueRuntimeException when current job is not cleared before setting a new one.
@return $this
Set current job