Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function __set($property, $value)
- {
- $this->{$property} = $value
- $this->update();
- }
- /**
- * Call this if you want to persist your property updates between fails or retries.
- * This will update "payload".
- **/
- public function update()
- {
- // get top level Job (\Illuminate\Queue\Jobs\Job)
- $job = $this->job;
- $refobject = new \ReflectionObject($job);
- // get it's job property
- $jobrecord = $refobject->getProperty('job');
- $jobrecord->setAccessible(true);
- // create a new reflection object of the next job property ($jobrecord)
- $record = $jobrecord->getValue($job);
- $refobject = new \ReflectionObject($record);
- // with our new reflection object, access the record property
- $recordproperty = $refobject->getProperty('record');
- $recordproperty->setAccessible(true);
- // get the record property and fetch the payload from it.
- $record = $recordproperty->getValue($record);
- $payload = $record->payload;
- $payload = \json_decode($payload, true);
- // keep job, but null it while we serialize as we don't need it to be stored.
- $job = $this->job;
- $this->job = null;
- // overwrite the serialized object with a new copy of it.
- $payload['data']['command'] = \serialize($this);
- // reset the job after serialization
- $this->job = $job;
- $record->payload = \json_encode($payload);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement