public function createJob($jobName, $data = null, $notBefore = null, $reference = null)
    {
        $data = [
            'type' => $jobName,
            'data' => $data,
            'reference' => $reference,
        ];
        if ($notBefore !== null) {
            $data['notbefore'] = new Time($notBefore);
        }
        $queue = $this->newEntity($data);
        if ($queue->errors()) {
            throw new Exception('Invalid entity data');
        }
        return $this->save($queue);
    }
public function createJob($jobName, $data = null, $notBefore = null, $reference = null)
    {
        $data = [
            'type' => $jobName,
            'data' => $data,
            'reference' => $reference,
        ];
        if ($notBefore !== null) {
            $data['notbefore'] = new Time($notBefore);
        }
        $queue = $this->newEntity($data);
        if ($queue->errors()) {
            throw new Exception('Invalid entity data');
        }
        return $this->save($queue);
    }
public function createJob ( $ jobName , $ data = null , $ notBefore = null , $ reference = null ) { $ data = [ 'type' => $ jobName , 'data' => $ data , 'reference' => $ reference , ] ; if ( $ notBefore !== null ) { $ data [ 'notbefore' ] = new Time ( $ notBefore ) ; } $ queue = $ this -> newEntity ( $ data ) ; if ( $ queue -> errors ( ) ) { throw new Exception ( 'Invalid entity data' ) ; } return $ this -> save ( $ queue ) ; }
Add a new Job to the Queue.

@param string $jobName   QueueTask name
@param array|null $data      any array
@param array|null $notBefore optional date which must not be preceded
@param string|null $reference An optional reference string.
@return \Cake\ORM\Entity Saved job entity
@throws \Exception
Add a new Job to the Queue .